Search code examples
mql4

How identify previous low or high from zigzag


this is icustom calling function and get low ang high value.

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

And how can code previous low and high value to compare as

if previous low > current low ,continue trend

if previous low < current low ,trend change

zigzag


Solution

  • the last placeholder at the function "iCustom(......,X)" is the number of the Bar u want to check in your code: double highzigzag = iCustom(NULL,0,"ZigZag",InpDepth,InpDeviation,InpBackstep,1,HERE); double lowzigzag = iCustom(NULL,0,"ZigZag",InpDepth,InpDeviation,InpBackstep,2,HERE);

    u are checking with 0 = Current OpenBar

    u need to change it to 1=First Finished Bar or 2=Second Finished Bar as example

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

    in this example i'm checking the first finished bar but instead of typing the bar number u should use the function within a for-loop and replace the bar number through "i"

    if it helps dont forget to like