如何从锯齿形中识别先前的低点或高点

How identify previous low or high from zigzag

这是icustom调用函数,获取低值和高值。

double highzigzag = iCustom(NULL,0,"ZigZag",InpDepth,InpDeviation,InpBackstep,1,0);
      double lowzigzag = iCustom(NULL,0,"ZigZag",InpDepth,InpDeviation,InpBackstep,2,0);

以及如何将先前的低值和高值编码为进行比较

如果前期低点 > 当前低点,继续趋势

如果前期低点<当前低点,趋势改变

zigzag

函数“iCustom(......,X)”的最后一个占位符是您要在代码中签入的栏的编号:double highzigzag = iCustom(NULL,0,"ZigZag",InpDepth,InpDeviation,InpBackstep,1,HERE); double lowzigzag = iCustom(NULL,0,"ZigZag",InpDepth,InpDeviation,InpBackstep,2,HERE);

您正在检查 0 = 当前 OpenBar

您需要将其更改为 1=First Finished Bar 或 2=Second Finished Bar 例如

double highzigzag = iCustom(NULL,0,"ZigZag",InpDepth,InpDeviation,InpBackstep,1,1);
  double lowzigzag = iCustom(NULL,0,"ZigZag",InpDepth,InpDeviation,InpBackstep,2,1);

在这个例子中,我检查的是第一个完成的柱,但不是键入柱编号,你应该使用 for-loop 中的函数并通过“i”替换柱编号

如果有帮助别忘了点赞

只是为了完成@noSkill06s 所说的,这里是循环

int    longRange  = 100;
double highzigzag = 0,
       lowzigzag = 0;

for(int i = 1;i<longRange;i++){

    highzigzag = 
iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",InpDepth,InpDeviation,InpBackstep,1,i);
   if(highzigzag!=0) break;

}

for(int i = 1;i<longRange;i++){

lowzigzag = 
iCustom(Symbol(),PERIOD_CURRENT,"ZigZag",InpDepth,InpDeviation,InpBackstep,2,i);
if(lowzigzag!=0) break;

}


Comment("hight :"+highzigzag +"\nLow : "+lowzigzag );