From a74b5db8f777b458e7953c483520f8c8a7da645b Mon Sep 17 00:00:00 2001 From: Garfield Date: Tue, 24 Mar 2026 14:52:42 -0400 Subject: [PATCH] Fix MT5 array declaration issues in OrdersEA_Smart_Grid Changed dynamic arrays to fixed-size arrays: - MqlRates rates[] -> rates[1] - double rsiBuf[] -> rsiBuf[1] - double adxBuf[] -> adxBuf[1] - double atrBuf[] -> atrBuf[1] - Removed ArraySetAsSeries calls (not needed for fixed arrays) This fixes common 'array out of range' errors in MT5. --- OrdersEA_Smart_Grid.mq5 | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/OrdersEA_Smart_Grid.mq5 b/OrdersEA_Smart_Grid.mq5 index 7611c25..b220a4c 100644 --- a/OrdersEA_Smart_Grid.mq5 +++ b/OrdersEA_Smart_Grid.mq5 @@ -119,8 +119,7 @@ bool S1HitToday = false; //+------------------------------------------------------------------+ void CalculatePivotPoints() { - MqlRates rates[]; - ArraySetAsSeries(rates, true); + MqlRates rates[1]; int copied = CopyRates(_Symbol, PERIOD_D1, 1, 1, rates); if(copied < 1) @@ -144,8 +143,7 @@ void CalculatePivotPoints() double atr = 0; if(ATRHandle != INVALID_HANDLE) { - double atrBuf[]; - ArraySetAsSeries(atrBuf, true); + double atrBuf[1]; if(CopyBuffer(ATRHandle, 0, 0, 1, atrBuf) > 0) atr = atrBuf[0]; } @@ -173,8 +171,7 @@ bool IsRangingMarket() if(UseRSIFilter && RSIHandle != INVALID_HANDLE) { - double rsiBuf[]; - ArraySetAsSeries(rsiBuf, true); + double rsiBuf[1]; if(CopyBuffer(RSIHandle, 0, 0, 1, rsiBuf) > 0) { double rsi = rsiBuf[0]; @@ -188,8 +185,7 @@ bool IsRangingMarket() if(UseADXFilter && ADXHandle != INVALID_HANDLE && isRanging) { - double adxBuf[]; - ArraySetAsSeries(adxBuf, true); + double adxBuf[1]; if(CopyBuffer(ADXHandle, 0, 0, 1, adxBuf) > 0) { double adx = adxBuf[0];