Try replacing;
int MA_Volume_Period = 100;
by
#define MA_Volume_Period 100;
(and check the overall appearance hereafter!)
As far as I remember arrays must not be declared using a variable:
double m1_volume_history[MA_Volume_Period];
But maybe this has changed meanwhile - I don't know as I have avoid it.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Environment:
Problem Description:
While developing an Expert Advisor that operates based on M1 data, I've encountered a persistent and apparently incorrect compilation error: '[' - invalid index value .
The error occurs within an if block that detects a new M1 bar. Inside this block, several C opyBuffer calls are made to retrieve data from indicators (MAs, ATR) and the iVolumes indicator.
The specific issue arises when trying toaccess or perform calculations using the copied data immediately after the sequence of CopyBuffer calls. The "invalid index value" error message is reported on lines where either there is no index access ( [ ), or the index access should be valid (as the copy success was checked). The exact line number reported varies slightly depending on the code structure but consistently occurs after the CopyBuffer calls and before or duringthe use of the copied data.
The errordoes NOToccur if:
The errorDOES occurconsistently when:
This strongly suggests a bug in the parser or compiler of build 4885, which gets confused by this specific sequence of operations, reporting an incorrect error. Cleaning the code file (copy/paste via plain text editor) and performing a full Rebuild did not resolve the issue.
MRE Code - Step 1 (Compiles OK):This code includes all necessary CopyBuffer calls but does not attempt to use the results beyond a simple Print statement. It compiles successfully.
MRE Code - Step 2 (Fails to Compile):This code is identical to Step 1, but adds the block of calculations and variable assignments after the CopyBuffer calls. This version fails to compile.Exact Error Message When Compiling MRE - Step 2:
'[' - invalid index value BugTestInvalidIndex_Step2.mq5 67 31
(Note: The line number '67' may vary slightly based on formatting, but the error consistently occurs at the if(!data_ok) check line afterthe CopyBuffer calls when the subsequent calculation/assignment block is present).
Additional Observation:
The error seems related to the sequence of c opy Buffer calls followed by calculations/assignments within the same scope, possibly indicating a parser bug in the compiler for this specific pattern.