how to create a function call with dynamic array as an input variable?
have go thru the function call material, however it does not mention how to pass the dynamic array variable
the following code work fine in MT4
double AddArray(int X, arr[,])
{
return(arr[X,0] + arr[X,1]);
}
double arr[10,5]; // this create a 10 row n 5 column array
AddArray(0,arr);
however it will have compilation error in MT5
',' - unexpected token
You should properly insert code. Here you are
//+------------------------------------------------------------------+ //| TestArrayCall.mq5 | //| Copyright 2010, MetaQuotes Software Corp. | //| http://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2010, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property version "1.00" //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- double arr[][5]; ArrayResize(arr,10); // this create a 10 row n 5 column array AddArray(0,arr); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ double AddArray(int X,double &arr[][5]) { return(arr[X][0]+arr[X][1]); } //+------------------------------------------------------------------+
how to create a function call with dynamic array as an input variable?
in MT4 normally is it define as follow
bool functionName(double variablename[,])