大师你好!
有人给出了这一段程序,但是我看不懂!请大师指点!
{
int limit,n,k=5,cout;
int counted_bars=IndicatorCounted();
double zigpoint[2];
datetime zigtime[2];
ArrayInitialize(zigpoint,0.0);
for(cout=0;cout<2;cout++)
{
while (zigpoint[cout]==0.0)
{
zigpoint[cout]=iCustom(NULL,0,"Zigzag",12,5,3,0,k);
zigtime[cout]=Time[k];
k++;
}
k++;
}
for(cout=0;cout<2;cout++)
{
if (zigpoint[cout]>=Bid)
{
Print("The Count is ",cout,",| zigpoint=",DoubleToStr(zigpoint[cout],Digits),",| zigtime=",TimeToStr(zigtime[cout],TIME_DATE|TIME_SECONDS));
}
return(0);
}
上面这段代码除了画最近的最高点的,之前的几个最低最高点也可以画出来
int limit,n,k=5,cout;
int counted_bars=IndicatorCounted();
double zigpoint[4];
datetime zigtime[4];
ArrayInitialize(zigpoint,0.0);
for(cout=0;cout<4;cout++)
{
while (zigpoint[cout]==0.0)
{
zigpoint[cout]=iCustom(NULL,0,"ZigZag",12,5,3,0,k);
zigtime[cout]=Time[k];
k++;
}
k++;
}
for(cout=0;cout<4;cout++)
{
// if (zigpoint[cout]>=Bid)
{
Print("The Count is ",cout,",| zigpoint=",DoubleToStr(zigpoint[cout],Digits),",| zigtime=",TimeToStr(zigtime[cout],TIME_DATE|TIME_SECONDS));
}
}
ObjectCreate("水平线",OBJ_HLINE,0,zigtime[0],zigpoint[0]);
//ObjectCreate("折线",OBJ_TREND,0,zigtime[0],zigpoint[0],zigtime[1],zigpoint[1]);
//ObjectCreate("折线2",OBJ_TREND,0,zigtime[1],zigpoint[1],zigtime[2],zigpoint[2]);
这段程序我后来在使用的过程中发现有问题,最后一个k++是多余的,加了会导致错误。后来我选择下面的循环方式:
for(cout=0;cout<4;cout++)
{
for( ;zigpoint[cout]==0.0;k++)//for的第一位置是空的
{
zigpoint[cout]=iCustom(NULL,0,"ZigZag",12,5,3,0,k);
zigtime[cout]=Time[k];
}
}
不知道谁是原程序的作者方便的话出来澄清一下
请教大师,我想在图表上,用Zigzag.mq4这个指标的最近一个高点或底点画一条水平的线,请问如何设计这段程序!
请高手给一段程序,在此先拜谢!