ZigZag Function without involving indicator buffer.

 

Dear Coders

I know that there is already ZigZag custom Indicator in both.

However I am looking for a ZigZag Function which does the same job as ZigZag Custom Indicator.

For eample, I need something like this.



//This should work on MQL5 language. Code must be self sufficient without any dependency. Can include other function like iHighest or iLowest. But code must be portable.    
//Implementing Zig Zag logic without indicator buffer involes.
//Input:: high = high price series, low = low price series, depth = zig zag depth, deviation = zigzag deviation, backstep = zig zag back step
//Output:: zigzag = final zigzag seires (output)

void ZigZagFunction(double &high[], double &low[], double &zigzag[], int depth, int deviation, int backstep)
{
    //implementing usual Zig Zag Logic as in ZigZag.mq4 or ZigZag.mq5. 

}


Does any one come across ZigZag logic in function or from any forum or from any blog?

Then please share any link or your ideas here.

Thanks so much in advance. Look forward to hearing from you.

Kind regards.

 
its a bad idea each time when you are call this function it will be calculate all bars
 
You could call Zig Zag indicator. No need to internal function. What's the aim for this??. Regards
 
Aleksei Beliakov #:
its a bad idea each time when you are call this function it will be calculate all barsH
Aleksei Beliakov #:
its a bad idea each time when you are call this function it will be calculate all bars

hey buddy, I want to develop a EA without using indicator, one ideas that came to my mind was using a built in zigzag function in expert advisor to clearly find pivot and after that expand ea and test strategy, could you please do a favor to me and help me in this journy?

 
thank you for you advise I want to test all of idea but I'm new in this way is there a way to create menu to get input from a menu on chart to give them to ea?
 
Young Ho Seo:

I know that there is already ZigZag custom Indicator in both.

However I am looking for a ZigZag Function which does the same job as ZigZag Custom Indicator.

Don't try to do that. There are no buffers, no IndicatorCounted() or prev_calculated. No way to know if older bars have changed or been added (history update.)

Just get the value(s) of the indicator(s) into EA/indicator (using iCustom) and do what you want with it.
          Detailed explanation of iCustom - MQL4 programming forum (2017)

 

https://www.mql5.com/en/code/39114

I have this running around for quite some time now but I guess it was about time to finish it for publishing.

You can enter the respective array size instead of rates total.

ZigZagExtremaOnArray
ZigZagExtremaOnArray
  • www.mql5.com
The ZigZagExtremaOnArray is an mqh include file which contains the calculation function of MetaQuotes' Examples ZigZag, BUT you can use it on any buffer that contains curves or histograms, similarly to the MovingAverages.mqh from include. The idea was to get highs and lows of an indicator curve quickly with the help of an "onBuffer" function.
Reason: