Not getting alert or notification.

 

Hello,

I created a MLQ5 expert advisor code. I compile and it says no error. I created an alert about RSI crossing 50 alert. However  I did not receive any alert. 


Can someone please help me. 


I created a code - 

//+------------------------------------------------------------------+

//|                                            RSI_Alert_Full.mq5   |

//|                        Copyright 2024, MetaQuotes Software Corp. |

//|                                             https://www.mql5.com |

//+------------------------------------------------------------------+

#property strict


// Input parameters

input int RSI_Period = 15;      // RSI period

input ENUM_TIMEFRAMES Timeframe = PERIOD_H1;  // Timeframe for RSI calculation

input double Alert_Level = 50;   // RSI level for alert


//+------------------------------------------------------------------+

//| Expert initialization function                                   |

//+------------------------------------------------------------------+

int OnInit()

{

    // Subscribe to the OnTimer event

    EventSetTimer(60); // Check every minute

    

    return INIT_SUCCEEDED;

}


//+------------------------------------------------------------------+

//| Expert deinitialization function                                 |

//+------------------------------------------------------------------+

void OnDeinit(const int reason)

{

    // Remove the timer

    EventKillTimer();

}


//+------------------------------------------------------------------+

//| Expert timer function                                            |

//+------------------------------------------------------------------+

void OnTimer()

{

    // Calculate RSI value

    double rsi = iRSI(_Symbol, Timeframe, RSI_Period, 0);


    // Calculate previous RSI value

    double prev_rsi = iRSI(_Symbol, Timeframe, RSI_Period, 1);


    // Check if RSI crossed the alert level (both bullish and bearish)

    if (((rsi > Alert_Level) && (prev_rsi <= Alert_Level)) || ((rsi < Alert_Level) && (prev_rsi >= Alert_Level)))

    {

        // Send alert

        if (rsi > Alert_Level)

            Alert("RSI Alert: RSI crossed above 50 on hourly timeframe!");

        else

            Alert("RSI Alert: RSI crossed below 50 on hourly timeframe!");

    }

}


//+------------------------------------------------------------------+
Discover new MetaTrader 5 opportunities with MQL5 community and services
Discover new MetaTrader 5 opportunities with MQL5 community and services
  • 2024.02.27
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions