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

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

author EAcpu | 4 reads | 0 comments |

Divergences Template Indicator - indicator for MetaTrader 4

Divergences Template Indicator - indicator for MetaTrader 4

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

The indicator has four different buffers as follows to track the generated signals. The signal is emitted whenever the corresponding buffer holds a non-null value.
 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

Verification code Refresh