インディケーターの線の色や太さの設定 〜 SetIndexStyle関数

インディケーター作って表示してみたけど、何も見えない。
線の色が背景色と同じだったから・・・。

//+------------------------------------------------------------------+
//| 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);
  }
//+------------------------------------------------------------------+

SetIndexStyle(0, DRAW_LINE, EMPTY, 2, Red);
を使用して線種、線の色、太さを指定する。

サンプルなのでstart()関数に書いているけど、init()に書くのが普通だと思う。

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   //Start Init
   SetIndexStyle(0, DRAW_LINE, EMPTY, 2, Red);  
   //End init
   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);
  }
//+------------------------------------------------------------------+