Is there a way to quantify the high and low of the waves in a trend?

 

Dear all

By visual, we can easily identify that price runs in trend form, the high and low of every wave, and the direction of a wave.

However, does anybody know, how to let EA to do it? Does any one has an idea on it?

Thanks for your kind help!

Wing

 
You code it just like how you'd reason it, up trend or down, find the high, find the low ignore minor movements.
        int iHi = LocalExtremeBar(LE.Window, 1, +1),
            iLo = LocalExtremeBar(LE.Window, 1, -1);
        if (iHi > iLo){ int iOld = iHi, iNew = iLo, DIRold = +1;    }
        else{               iOld = iLo; iNew = iHi; DIRold = -1;    }
        while(true){
            // old \|LE.Window|       /
            //      \     /\         /
            //       \   /  \/\/\/\ /
            //        \ /          V new
            //         V |LE.Window|
            iNew = MaximalBar(iOld - iNew + 1, iNew, -DIRold);
            double  pOld    = MaxPrice(iOld, +DIRold),
                    pNew    = MaxPrice(iNew, -DIRold),
                    range   = MathAbs(pNew - pOld);
            if (range >= rangeMin)  break;                      // Large enough.
            if (iOld == Bars - 1)   break;                      // No history.
            iNew    = iOld;         DIRold  = -DIRold;
            iOld    = LocalExtremeBar(LE.Window, iNew+1, DIRold);
        }   // while
        double  LL   = MathMin(pNew, pOld),
See my code
 

You can(are able), if you find the next possible high/low of the current chart(TF) ie. example:

-Current: Average Bar (known), added difference between median[1]-median[2] (it can correlation + median[2]-median[3]), that is if trend is established - rising or lowering difference add and could be possible next median[-1] or [0], with average bar can HiLo.

- > Same procedure for Higher time-frame where wave is not visible (ie. within bars), = lowWave/highWave.

Small ps: There are more average bars counting's possible,..

1.) Standard - add all then divide by bars number.

2.) No Spikes averages, = 2 loops, 1st is standard, 2nd is filtered from spikes.

3.) Standard average rise to Spikes by same procedure as 2.).

 
Some may use the Zig Zag indicator for this purpose.
Reason: