//+------------------------------------------------------------------+ //| Sample_Indicator_01.mq4 | //| Dr.EA Keiji | //| https://www.dr-ea.com/meta-blog/ | //+------------------------------------------------------------------+ #property copyright "Dr.EA Keiji" #property link "https://www.dr-ea.com/meta-blog/" #property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 1 // インジケーターバッファ 1つ #property indicator_color1 clrRed // 1つ目の色 赤色 #property indicator_width1 2 // 1つ目の太さ 2 double buf[]; // ライン用の配列を宣言 //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0, buf); // 配列 buf[]をインジケーター用に割り当てる SetIndexStyle(0, DRAW_LINE); // 描画タイプをラインと定義 //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- buf[0] = Close[0]; // 現在プライスを代入 //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+