Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

ZigZagExtremaOnArray - MetaTrader 5 Library - MT4/MT5 Resources

author EAcpu | 3 reads | 0 comments |

ZigZagExtremaOnArray - library for MetaTrader 5

ZigZagExtremaOnArray - library for MetaTrader 5

ZigZagExtremaOnArray - library for MetaTrader 5

ZigZagExtremaOnArray - library for MetaTrader 5

ZigZagExtremaOnArray - library for MetaTrader 5

ZigZagExtremaOnArray - library for MetaTrader 5

 integer calculation ( const integer rate_total,
constant integer previously calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
constant length &tick_volume[],
const long &volume[],
const int & spread[]) {

Integer to_copy = (rates_total - prev_calculated) * (prev_calculated < rates_total) + ( 1 ) * (prev_calculated == rates_total);
copy buffer (RSI handle, 0 , 0 , to_copy, ExtRSIBuffer);

//--- ZigZagExtremaOnBuffer.mqh calculation function ZZOnBuffer(rates_total, prev_calculated, ExtRSIBuffer, ExtOutputBuffer, InpSearchMode, InpDepth, InpDeviation, InpBackstep);

return (rate_total);
}


To get only the highs or only the lows, add an input of type EnSearchmode:

 //+------------------------------------------------------------------+
//|Zigzag line calculation |
//+------------------------------------------------------------------+
Integer ZZOnBuffer ( constant integer rates, //On non-metric arrays, Arraysize can be calculated as 'rates_total' constant integer ,
const double &src[], //compute source buffer double &dst[], //compute destination buffer of buffer EnSearchMode mode_search, //set output buffer to only high, only low, or both constant int &depth,
constant integer & deviation,
Constant integer one step back (&B) //ZZ input parameters ) { ...
                        ...

High points only:

ZigZagExtremaOnArray - library for MetaTrader 5

ZigZagExtremaOnArray - library for MetaTrader 5

The highs and lows are both in a buffer:

ZigZagExtremaOnArray - library for MetaTrader 5

It is not limited to indicator buffers, you can use it on any array, just set "rates" to the length of the array instead of rates_total.

The absolute minimum number of bars that this function can handle is 100. So, although you can use this calculation function on an array of hundreds of bars, in the indicator buffer rates_total is usually several thousand.


Attachment download

📎 zigzagextremaonbuffer.mqh (8.26 KB)

📎 testrsizzxonbuffer.mq5 (3.32 KB)

Source: MQL5 #39114

Verification code Refresh