Where? Look at the error message again in the log and see which line and character position is reported for the error.
Please don't post randomly in any section. MT4/mql4 has it's own section on the forum.
I have moved your topic to the correct section, so please don't create another topic.
You are mixing Indicator code with EA code.
Is this an Indicator or an EA?
-
void OnTick() {
Only EAs use OnTick, yet you try to have buffers which are only in indicators.
-
int counted_bars = IndicatorCounted();
Only indicators can use that, yet you have EA code.
-
AO[i] = iAO(NULL, 0, AO_Period);
Invalid MT4 call. MT5 code.
-
ticket=OrderSend(Symbol(), OP_SELL, Lots, Bid, 3, Bid + StopLoss * Point(), Bid - TakeProfit * Point(), "Sell”, MagicNumber);
MT4 EA only calls.
Stop using ChatGPT.
Help needed to debug and fix an AI EA - Trading Systems - MQL5 programming forum #2 (2023)
Do not post code that will not even compile. You didn't get your “Critical Error” with that posted code.
Where? Look at the error message again in the log and see which line and character position is reported for the error.
for (int i = limit; i >= 0; i--) { EMA_Fast[i] = iMA(NULL, 0, EMA_Fast_Period, 0, MODE_EMA, PRICE_CLOSE, i); EMA_Slow[i] = iMA(NULL, 0, EMA_Slow_Period, 0, MODE_EMA, PRICE_CLOSE, i); BB_Upper[i] = iBands(NULL, 0, BB_Period, BB_Deviation, 0, PRICE_CLOSE, MODE_UPPER, i); BB_Lower[i] = iBands(NULL, 0, BB_Period, BB_Deviation, 0, PRICE_CLOSE, MODE_LOWER, i); AO[i] = iAO(NULL, 0, AO_Period); }
Thank You. I got the error here
-
Only EAs use OnTick, yet you try to have buffers which are only in indicators.
-
Only indicators can use that, yet you have EA code.
-
Invalid MT4 call. MT5 code.
-
MT4 EA only calls.
Stop using ChatGPT.
Help needed to debug and fix an AI EA - Trading Systems - MQL5 programming forum #2 (2023)
Do not post code that will not even compile. You didn't get your “Critical Error” with that posted code.
I understand thank you for your reply.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi guys, I am trying to develop an EA based on few indicator But When I attached to a chart got this massage "Critical Error While Running Expert, Array Out Of Range"
Please help me to fix this error thank you in advance. Here is my code: