Big problem: array out of range (3297,29)
-
Hallo Admin,
- no red errors when compiling
- no error message during the optimization
But during trading, the EA is removed from the chart and the following error messages appear.
II 0 18:40:16.761 Var2_2.1cr (GBPUSD.m,M5) Terminal has been closed
NL 0 18:40:59.729 Myfxbook (CHFJPY.m,H1) log -- Myfxbook EA Version 1.63
CJ 0 18:40:59.730 Myfxbook (CHFJPY.m,H1) log -- Show_Log mode: 1
JK 0 18:40:59.744 Myfxbook (CHFJPY.m,H1) log -- Debug mode: 0
NH 2 18:40:59.786 Var3_1.0 (AUDCAD.m,M5) array out of range in 'Var3_1.0.mq5' (3297,29)
CD 2 18:40:59.799 Var3_1.0 (AUDCHF.m,M5) array out of range in 'Var3_1.0.mq5' (3297,29)
QQ 2 18:41:20.235 Var3_1.0 (AUDCHF.m,M5) array out of range in 'Var3_1.0.mq5' (3297,29)
HN 2 18:41:38.597 Var3_1.0 (AUDCAD.m,M5) array out of range in 'Var3_1.0.mq5' (3297,29)
JH 0 18:41:56.
195 Myfxbook (CHFJPY.m,H1) Statement uploaded successfully
CQ 0 18:42:58.039 Var2_2.1cr (GBPUSD.m,M5) Terminal has been closed
NJ 0 18:42:58.039 Var3_1.0 (EURUSD.m,M5) Terminal has been closed
JL 0 18:43:02.359 Myfxbook (CHFJPY.m,H1) log -- Myfxbook EA Version 1.63Is the failture known and can you tell me why this is going on?
-
// "Once per bar" model
template<typename T1,typename T2,typename T3>
class MDL_OncePerBar: public BlockCalls
{
public: /* Input Parameters /
T1 Symbol;
T2 Period;
T3 PassMaxTimes;
/ Static Parameters */
string tokens[];
int passes[];
datetime old_values[];
datetime time[];
virtual void callback(int r) {return;}public: /* Constructor */ MDL_OncePerBar() { Symbol = (string)CurrentSymbol(); Period = (ENUM_TIMEFRAMES)CurrentTimeframe(); PassMaxTimes = (int)1; } public: /* The main method */ virtual void _execute_() { // this is static for speed reasons bool next = false; string token = Symbol + IntegerToString(Period); int index = ArraySearch(tokens, token); if (index == -1) { index = ArraySize(tokens); ArrayResize(tokens, index + 1); ArrayResize(old_values, index + 1); ArrayResize(passes, index + 1); tokens[index] = token; passes[index] = 0; old_values[index] = 0; } if (PassMaxTimes > 0) { CopyTime(Symbol, Period, 1, 1, time); **datetime new_value = time[0];** if (new_value > old_values[index]) { passes[index]++; if (passes[index] >= PassMaxTimes) { old_values[index] = new_value; passes[index] = 0; } next = true; } } if (next) {_callback_(1);} else {_callback_(0);} }};
-
Hello,
do you have any idea what is going on?

-
@dieter No solution yet?
-
@fxDreema any idea?
-
In which timeframe are you testing the EA and which timeframe does the once-per-bar block use in which the error occurs? I've dealt with this error multiple times.