Hi,
I have a user-defined-class as follow:
and I managed to declare it as global array,
and I am able to access the array by declaring custom function to each array:
I try to simplify the function into one by doing the following:
But I have encountered errors as follow when called the below function:
'BuyPendingSetup' - parameter conversion not allowed SR Study v1.mq4 74 26
'SellPendingSetup' - parameter conversion not allowed SR Study v1.mq4 85 26
Appreciate if the following help could be provided:
1. The right way to code to pass user-defined-class array as parameter to function
2. Documentation related to passing user-defined-class as array
setup *BuyPendingSetup[]; setup *SellPendingSetup[]; setup *BuyRunningSetup[]; setup *SellRunningSetup[];
this is not declaration of global array of objects but declaration of array of pointers to must be previously constructed array/non array of object
void PendingReset(setup &PendingSetup[])
this will work if you pass array of existing objects as reference, what you passed is pointer
class A { int numbers; public: A() { numbers = 0;} void SetNo(int no) {numbers=no;}; int GetNo(){return(numbers);}; }; A aTest[]; A* atestPtr; A bTest[]; A *bTestPtr; A *cTest[]; int OnInit() { for (int i=0;i<6;i++) { ArrayResize(aTest,i+1); atestPtr = GetPointer(aTest[i]); atestPtr.SetNo(i); ArrayResize(bTest,i+1); bTestPtr = GetPointer(bTest[i]); bTestPtr.SetNo(i+1); } Print("================================================================================"); for (int j=0;j<ArraySize(aTest);j++) { Print("value of aTest",IntegerToString(j)," is ",aTest[j].GetNo()); } Print("================================================================================"); for (int k=0;k<ArraySize(bTest);k++) { Print("value of bTest",IntegerToString(k)," is ",bTest[k].GetNo()); } Print("================================================================================"); for (int l=0;l<ArraySize(bTest);l++) { ArrayResize(cTest,l+1); cTest[l] = GetPointer(bTest[l]); cTest[l].SetNo(l+2); } Print("================================================================================"); for (int m=0;m<ArraySize(bTest);m++) { Print("new value of bTest",IntegerToString(m)," changed by cTest",IntegerToString(m)," is ",cTest[m].GetNo()); } ResetValue(aTest,"aTest"); ResetValue(bTest,"bTest"); ChangeValue(cTest,"bTest","cTest"); return(INIT_SUCCEEDED); } void ResetValue(A &test[],const string objname) { Print("================================================================================"); for (int k=0;k<ArraySize(test);k++) { test[k].SetNo(0); Print("now value of ",objname,IntegerToString(k)," is ",test[k].GetNo()); } } void ChangeValue(A* &test[],const string objname,const string ptrname) { Print("================================================================================"); for (int k=0;k<ArraySize(test);k++) { test[k].SetNo(3); Print("new value ",objname,IntegerToString(k)," changed by ",ptrname,IntegerToString(k)," is ",test[k].GetNo()); } }see that above example if that can help you
this is not declaration of global array of objects but declaration of array of pointers to must be previously constructed array/non array of object
this will work if you pass array of existing objects as reference, what you passed is pointer
see that above example if that can help youvoid PendingReset(setup* &PendingSetup[]){A reference to an array of pointers.
Have you tried: A reference to an array of pointers.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I have a user-defined-class as follow:
and I managed to declare it as global array,
and I am able to access the array by declaring custom function to each array:
I try to simplify the function into one by doing the following:
But I have encountered errors as follow when called the below function:
'BuyPendingSetup' - parameter conversion not allowed SR Study v1.mq4 74 26
'SellPendingSetup' - parameter conversion not allowed SR Study v1.mq4 85 26
Appreciate if the following help could be provided:
1. The right way to code to pass user-defined-class array as parameter to function
2. Documentation related to passing user-defined-class as array