Divergence Template Indicator - MetaTrader 4 Script | Forex Indicator Download - MT4/MT5 Resources - MetaTrader 5 Resources


This indicator provides a template for plotting divergence oscillators according to your expectations.
Depending on the oscillator you choose (whether it's CCI, RSI or your custom indicator), you can modify this part of the code:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Load indicator data into the indicator buffer //You can easily load the RSI Replace with any indicator you like integer bars = mathmax (rates_total-IndicatorCounted()-pivots_period, 1 ); for ( integer i = bar chart; i>= 0 ; i --) { indicator buffer[i] = RSI ( _SYMBOL , PERIOD_CURRENT , 14 , PRICE_CLOSE , i); } //End of load indicator section /////////////////////////////////////////////////////////////////////////////////////////
signal buffer
Set index buffer ( 3 , bull_reg_divBuffer); Set index buffer ( 4 ,bear_reg_divBuffer); Set index buffer ( 5 , bull_hid_divBuffer); Set index buffer ( 6 ,bear_hid_divBuffer);
Input section
Input integer pivot_period = 5 ; //Find the period of the indicator pivot Enter integer alarm confirmation candle = 1 ; //#confirmation candle (0=disable alarm)
Finding pivot highs and pivot lows in the indicator buffer depends on the pivot_period input. The larger the value you choose, the larger the fluctuations it will search for possible divergences.
Another input is alert_confirm_candles, which defines the number of bars to wait for confirmation signals. Divergence indicators mostly lag and send out a lot of false signals. The larger the value you choose, the longer you wait and the fewer false signals you get. Whether you want an on-time signal or a confirmed signal, it's a compromise.
Applications for pivot_period < 2 are generally not allowed.
Indicators that rely on pivot calculations must wait for pivot_periods to get confirmation of recent highs/lows. Therefore the indicator needs to redraw the signal pivot_period back in time.
Attachment download
📎divergence_template.mq4 (11.94 KB)
Source: MQL5 #48583
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •