Hi
- User
Hi
- Assistant
Hello! How can I assist you today?
- User
Build mql5 indicator when rsi below 30 alert to buy
- Assistant
Sure, I can help you with that. Please provide me with more details about the specific conditions for the RSI and the kind of alert you would like to receive when it falls below 30.
- User
Rsi period 14
- Assistant
Alright. I will provide you with the code for an MQL5 indicator that provides an alert when the RSI with a period of 14 falls below 30. Here's an example of how you can set it up:
#property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 input int rsiPeriod = 14; double rsiBuffer[]; int prevAlert = 0; // Custom indicator initialization function int OnInit() { SetIndexBuffer(0, rsiBuffer, INDICATOR_DATA); SetIndexStyle(0, DRAW_LINE); SetIndexLabel(0, "RSI"); SetIndexDrawBegin(0, rsiPeriod); IndicatorShortName("RSI Indicator"); SetIndexEmptyValue(0, 0.0); IndicatorDigits(Digits + 1); return(INIT_SUCCEEDED); } // Custom indicator calculation function int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { int limit = MathMax(rates_total - prev_calculated, rsiPeriod); ArraySetAsSeries(open, true); ArraySetAsSeries(high, true); ArraySetAsSeries(low, true); ArraySetAsSeries(close, true); for (int i = limit; i >= 0; i--) { rsiBuffer[i] = iRSI(Symbol(), 0, rsiPeriod, PRICE_CLOSE, i); if (rsiBuffer[i] < 30 && prevAlert == 0) { Alert("RSI is below 30 - Buy alert!"); prevAlert = 1; } else if (rsiBuffer[i] >= 30) { prevAlert = 0; } } return(rates_total); }
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.