![](/img/trans.png)
[英]Translate spine script (tradingview) to mql indicator (meta trader 4)
[英]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.