Array with the size of extern variable

 

Hi I would like to create an array with size of an extern variable. The below is code which generates error. Thanks for your time.

extern int bars=200;

double my_array[bars];
 
 

I am writing the code in MT4 and this function is the same as MT5, I use the function in the manual and it is still giving me error!

extern int bars=200;

double my_array[];

 ArrayResize(my_array,1,bars );


The error is undeclared identifier bars, however it is already defined as int external variable.



Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
 
zabanmail.info: The error is undeclared identifier bars, 
  1. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. Post all relevant code; there is no context. You can't have ArrayResize outside of a function.
  3. Do you understand that your code only makes the array a size of one?
Reason: