神龙通道指标不能输出第二条线,哪位大佬能帮忙改一下
siho166
|
4865 人阅读
|
23 人评论
|
2022-07-14
//+------------------------------------------------------------------+
//| MHDMT_XMA.mq4 |
//| Copyright 2022, CompanyName |
//| http://www.companyname.net |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Yellow
extern int U = 9;
extern int U1 = 9;
extern int mode = 2;
double ExtMapB1[];
double ExtMapB2[];
int iMin = 0;
int iMax = 0;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
//IndicatorBuffers(2);
SetIndexStyle(0, DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(0, ExtMapB1);
SetIndexStyle(1, DRAW_LINE,STYLE_SOLID,1);
SetIndexBuffer(1, ExtMapB2);
//IndicatorShortName("XMA(" + N + ")");
iMin = U;
iMax = U + U1;
SetIndexDrawBegin(0, iMin);
SetIndexDrawBegin(1, iMin);
return (0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int counted_bars = IndicatorCounted();
if(Bars <= iMax) return (0);
if(counted_bars > 0) counted_bars--;
int limit =Bars-counted_bars -1;
int m,n;
m=(iMin-1)/2;
n=(iMax-1)/2;
for(int i = 0; i < limit; i++)
{
double Con1=0.0;
if(i >= m)
{
for(int x = i-m; x <= i+m; x++) Con1 += Close[x];//(Close[x]); //循环20次,第1次累加(20.0 * (High[i + 0]),第2次累加(19.0 * (High[i + 1]),直到累加到()1*High[i + 19])
ExtMapB1[i] = (Con1/iMin);//第二个循环一次后,把20次累加的值/210.0赋给MidUpBuf数组
}
else
{
for(x = 0; x <=i+m; x++) Con1 += Close[x];
ExtMapB1[i] = (Con1+Con1 * (iMin-i*2-1)/(iMin+i*2+1))/iMin;
}
}
for(i=0; i < limit; i++)
{
double Con2=0.0;
if(i >= m)
{
for(x =i+m ; x > i-m; x++) Con2 += ExtMapB1[x];
ExtMapB2[i] = (Con2/iMin);
}
else
{
for(x = 0; x <=i+m; x++) Con2 += ExtMapB1[x];
ExtMapB2[i]= (Con2+Con2 * (iMin-i*2-1)/(iMin+i*2+1))/iMin;
}
}
return (0);
}
|
|
|
|
|
这里有很多神龙现成的,自己下个研究或者不用直接用,没人改 |
|
|
|
|