簡體   English   中英

Mql4 Meta trader4,當新柱形成時,我無法使指標與蠟燭同時向左移動

[英]Mql4 Meta trader4, I can not make the indicator shift left simultaneously with the candles when new bar is formed

以下是當前代碼。 指標編譯並運行當運行時,波浪與蠟燭一起移動作為新柱 forms。 但是,當您關閉平台一段時間然后重新打開時,蠟燭和罪波現在不再同步。 不知何故,子窗口回到平台打開時。 因此,92 名看起來很糟糕的人中沒有人願意解決這個問題。 我試着在這里放了3張圖片來幫助解釋,但是這里的系統不會顯示圖片。 如果您是一名試圖提供幫助的編碼人員,請在此處復制代碼並將其粘貼到您的平台中。 運行。 用不會移動的文本符號標記高峰值或低谷,然后在文本字符和其上方的蠟燭之間放置一條垂直線。 隨着程序的進行,垂直線將隨蠟燭移動,波浪隨垂直線移動,文本標記保持不變,因此您可以看到您從哪里開始。 然后在指標仍然加載的情況下關閉您的平台,等待幾個蠟燭周期,然后重新打開平台,您會看到波浪重置回右側。 垂直線繼續使用適當的蠟燭,並且文本標記也隨着正弦波的峰值或谷值重置到右側。

 //---- indicator settings
#property indicator_separate_window
#property indicator_buffers 8 // 7
#property indicator_color1 Red
#property indicator_color2 Orange
#property indicator_color3 Yellow
#property indicator_color4 Lime
#property indicator_color5 Blue
#property indicator_color6 DodgerBlue
#property indicator_color7 DarkViolet
#property indicator_color8 White



//---- indicator buffers
double ExtBuffer1[], ExtBuffer2[], ExtBuffer3[], ExtBuffer4[], 
ExtBuffer5[],ExtBuffer6[], ExtBuffer7[], ExtBuffer8[];     
double Dgr1[], Dgr2[], Dgr3[], Dgr4[], Dgr5[], Dgr6[], Dgr7[], 
Dgr8[];
extern datetime StartTime=D'1999.11.10 00:00';

//+-------------------------------------------------------------+
//| Custom indicator initialization function |
//+-------------------------------------------------------------+
int init()
{
IndicatorBuffers(7); // 6
SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,ExtBuffer1); 
SetIndexShift(0,295);       
SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,ExtBuffer2); 
SetIndexShift(1,264);     
SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(2,ExtBuffer3); 
SetIndexShift(2,203); 
SetIndexStyle(3,DRAW_LINE); SetIndexBuffer(3,ExtBuffer4); 
SetIndexShift(3,166);      
SetIndexStyle(4,DRAW_LINE); SetIndexBuffer(4,ExtBuffer5); 
SetIndexShift(4,74); 
SetIndexStyle(5,DRAW_LINE); SetIndexBuffer(5,ExtBuffer6); 
SetIndexShift(5,102); // DodgerBlue
SetIndexStyle(6,DRAW_LINE); SetIndexBuffer(6,ExtBuffer7); 
SetIndexShift(6,78); // Dark Violet
SetIndexStyle(7,DRAW_LINE); 
SetIndexBuffer(7,ExtBuffer8); SetIndexShift(7,85); // White



   SetLevelValue(0,0);
   SetIndexStyle(0,DRAW_LINE,0,3); // 0
   SetIndexStyle(2,DRAW_LINE,0,3); // 0
   SetIndexStyle(3,DRAW_LINE,0,3); // 0
   SetIndexStyle(4,DRAW_LINE,0,3); // 0
   SetIndexStyle(5,DRAW_LINE,0,3); // 0
   SetIndexStyle(6,DRAW_LINE,0,3); // 0
   SetIndexStyle(7,DRAW_LINE,0,3); // 0





return(0);
}
//+-------------------------------------------------------------+
//| Accelerator/Decelerator Oscillator |
//+-------------------------------------------------------------+
int start()
{
   int limit; //  -----------------------------mine

   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   //-----------------------------------------mine  

   int Shift;
   int i;
   int b; // mine
   Shift=iBarShift(Symbol(),PERIOD_CURRENT,StartTime);
   ArrayResize(Dgr1,Shift+1); 
   ArrayResize(Dgr2,Shift+1); 
   ArrayResize(Dgr3,Shift+1); 
   ArrayResize(Dgr4,Shift+1);
   ArrayResize(Dgr5,Shift+1); 
   ArrayResize(Dgr6,Shift+1); 
   ArrayResize(Dgr7,Shift+1); 
   ArrayResize(Dgr8,Shift+1);

   MyCalc(Shift,1);

   for(b=Shift; b<limit; b++) // mine
  { 
   for(i=Shift; i>=0; i--) // >
   {
      ExtBuffer1[i]=Dgr1[i];
      ExtBuffer2[i]=Dgr2[i];
      ExtBuffer3[i]=Dgr3[i];
      ExtBuffer4[i]=Dgr4[i];
      ExtBuffer5[i]=Dgr5[i];
      ExtBuffer6[i]=Dgr6[i];
      ExtBuffer7[i]=Dgr7[i];
      ExtBuffer8[i]=Dgr8[i];






   }
  } // mine
return(0);
}
//+-------------------------------------------------------------+
void MyCalc(int Shift, int Yhigh )   
{
   int i;
   for(i=Shift;i>=0;i--)
   {
      Dgr1[i]=i*2.5; Dgr2[i]=i*2.5; Dgr3[i]=i*2.5; Dgr4[i]=i*2.5; 
      Dgr5[i]=i*2.5;

      double val1=i*2.5;
      double val2=i*2.5;
      double val3=i*2.5;
      double val4=i*2.5;
      double val5=i*2.5;
      double val6=i*2.5;
      double val7=i*2.5;
      double val8=i*2.5;


      Dgr1[i]=MathSin(3.14159*val1/298)- 1/2 * Yhigh;
      Dgr2[i]=MathSin(3.14159*val2/149)- 1/2 * Yhigh;
      Dgr3[i]=MathSin(3.14159*val3/98)- 1/2 * Yhigh;
      Dgr4[i]=MathSin(3.14159*val4/75)- 1/2 * Yhigh;
      Dgr5[i]=.5*MathSin(3.14159*val5/60)- 1/2 * Yhigh;
      Dgr6[i]=.5*MathSin(3.14159*val6/48)- 1/2 * Yhigh;
      Dgr7[i]=.5*MathSin(3.14159*val7/42)- 1/2 * Yhigh;                                                                      
      Dgr8[i]=.5*MathSin(3.14159*val8/38)- 1/2 * Yhigh;

   }
    }

您的問題是指標在D'1999.11.10 00:00'開始繪制,但是由於該日期在您的可見圖表歷史中無疑不可用,因此指標開始重新繪制為最早可用的柱。 這在您運行指標時繼續,但是當重新啟動 MQL4 時,可見柱受到您的設置(工具>選項>圖表>圖表中的最大柱)的限制,並且在重新加載指標時再次恢復以在最早可用的柱開始繪制,該柱具有現在改變了。 正如我在原始評論中所述,您的計算與蠟燭沒有直接聯系,因此它們不會持續變化。 如果您希望使它們保持一致,請以某種方式使起點保持一致。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM