インディケーターの線の色や太さの設定 〜 プリプロセッサ命令

インディケーターの線の色や太さの設定 〜 SetIndexStyle関数」では関数を使用して、インディケーターの線種や色を変更した。

プリプロセッサ命令でも可能なので、メモ。

これらを使用する。他にも色々あるけど、その他は適宜調べる。
#property indicator_buffers 1 //指標バッファ
#property indicator_color1 Red //線の色
#property indicator_style1 STYLE_SOLID //線種
#property indicator_width1 1 //線の太さ

サンプル。

#property indicator_chart_window
#property indicator_buffers 1          //指標バッファ
#property indicator_color1 Red         //線の色
#property indicator_style1 STYLE_SOLID //線種
#property indicator_width1 1           //線の太さ

//指標バッファ
double Buf[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//Allocate Indicator Buffer
SetIndexBuffer(0, Buf);

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int   counted_bars=IndicatorCounted();
   int   limit = Bars-counted_bars;
   
   for(int i=limit-1; 0<=i; i--){
      Buf[i] = (Close[i] + Close[i+1] + Close[i+2] + Close[i+3])/4;
   }
   
   return(0);
  }
//+------------------------------------------------------------------+