どんな新人の質問でも、フォーラムを乱雑にしないように。プロフェッショナルは、通り過ぎないでください。Nowhere without you - 6. - ページ 25

 

Цикл от самого "старого" бара к самому "свежему": 

    for (int i = limit; i >= 0; i--);
 

インジケーターを若干修正。小数点以下まで正しくカウントされます。例えば、あるセクションでインジケーターが11のはずなのに、11.58と表示されています。

何が問題なのでしょうか?

vniz_1, vniz_2が0より大きくなるようにした。指標となる線に隙間を作りました。隙間をつないで色を変える方法、ただし、この隙間での指標は計算 しない。

//+------------------------------------------------------------------+
//|                                                         сила.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//--- input parameters
extern int       Period_MA_1=7;
extern int       Period_MA_2=7;
extern int       Period_MA_3=7;
//--- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
    int counted_bars=IndicatorCounted(),                      
    limit;
    double
    vniz_1,
    vniz_2,
    MA_1_t,                         
    MA_2_t,                           
    MA_3_t;
 
   if(counted_bars>0)
      counted_bars--;
   
   limit=Bars-counted_bars;
   
   
   for(int i=0;i<limit;i++)
   {
      MA_1_t=iMA(NULL,0,Period_MA_1,0,MODE_EMA,PRICE_CLOSE,i+1);  
      MA_2_t=iMA(NULL,0,Period_MA_2,0,MODE_EMA,PRICE_CLOSE,i+2);  
      MA_3_t=iMA(NULL,0,Period_MA_3,0,MODE_EMA,PRICE_CLOSE,i+3);    
      vniz_1=(MA_3_t-MA_2_t);
      vniz_2=(MA_2_t-MA_1_t);
      if (vniz_1>0&&vniz_2>0)
      {
      ExtMapBuffer1[i]=(vniz_1/vniz_2);
      }
   }
   return(0);
  }
//+------------------------------------------------------------------+
 
Forexman77:

インジケーターを若干修正。小数点以下まで正しくカウントされます。例えば、あるセクションでインジケーターが11のはずなのに、11.58と表示されています。

何が問題なのでしょうか?

vniz_1, vniz_2が0より大きくなるようにした。指標となる線に隙間を作りました。隙間をつないで色を変える方法、ただし、この隙間での指標は計算しない。


      MA_1_t=iMA(NULL,0,Period_MA_1,0,MODE_EMA,PRICE_CLOSE,i+1);  
      MA_2_t=iMA(NULL,0,Period_MA_2,0,MODE_EMA,PRICE_CLOSE,i+2);  
      MA_3_t=iMA(NULL,0,Period_MA_3,0,MODE_EMA,PRICE_CLOSE,i+3); 
存在しないバーでインジケータを計算する ?・・・・・・?
 
      if (vniz_1<0 || vniz_2<0)
      {
      ExtMapBuffer2[i]=(чему равны разрывы);
      }
 
2013.07.07 16:06:21 2010.02.01 01:56 EURUSD,H1: Error in opening EURUSD sell orderArray index- out of range
?!!??
 
以下は、すべてのバーに対して水平線を 引くシンプルなインジケーターのコードです。
最後の20バーだけ線を引くようにするにはどうしたらいいですか?




#property indicator_separate_window
#property indicator_buffers 1

#property indicator_color1 Chocolate
#property indicator_width1 6

#property indicator_minimum -0.1
#property indicator_maximum  0.1


double ExtMapBuffer[];



int init() {

   IndicatorBuffers(1);
   IndicatorDigits(   Digits+2);
   IndicatorShortName("H_LINE");

   SetIndexLabel(    0, "H_LINE");
   SetIndexDrawBegin(0, 0);
   SetIndexStyle(    0, DRAW_LINE);
   SetIndexBuffer(   0, ExtMapBuffer);

   SetIndexEmptyValue(0, EMPTY_VALUE);
   SetIndexShift(     0, 0);

   return(0);
}




int start()  {

   int limit;
   int counted_bars=IndicatorCounted();

   if(counted_bars>0) {
      counted_bars--;
   }

   limit=Bars-counted_bars;


   for(int i=0; i<limit; i++) {   
      ExtMapBuffer[i] = 0;
   }


   return(0);
}
 
atztek:
以下は、すべてのバーに対して水平線を引くシンプルなインジケーターのコードです。
最後の20バーだけ線を引くようにするにはどうしたらいいですか?






線は何と同じにすればいいのでしょうか?
 
Vinin:

線は何と同じにすればいいのでしょうか?

この場合、Y軸の線のサイズは重要ではありません。これは、インジケータによる「描画」を特定の数のバーに 適切に制限する方法を理解するための例に過ぎません。
 
atztek:

Y軸の線の大きさはこの場合問題ではありません。これは、インジケータによる「描画」を特定の数のバーに制限する方法を理解するための例に過ぎません。

インジケーターバッファと オブジェクトのどちらを使用するか?
 
Vinin:
インジケーターバッファとオブジェクトのどちらを使用するか?

将来的には直線だけでなく、移動平均線などにも利用できるようになるため、インジケーターバッファも 用意しました。