Hi guys,
thanks for actively responding my first question, much appreciated.
Here is my second question of the my first day.
I have a function called "double removeDuplicatedOrder()" return a double Array, which contains a list of pending order price in double. The "removeDuplicatedOrder()" will be called and the return value from assinged to another double Array(called newPending_Order) in a function called "void processOrderList()". My problem when the "newPending_Order" gets retrun value from "double removeDuplicatedOrder()", i do a print function, which gives me a "all ZERO" empty list.
i have use "=" and ArrayCopy() to get the value and assinged to "newPending_Order", neither is working well. please help. Thanks in advance.
the follow is my code example:
You can't return an array from a function, instead pass the array by reference . . .
https://www.mql5.com/en/forum/139964 or https://www.mql5.com/en/forum/117484 and others, use Google . . .
You can't return an array from a function, instead pass the array by reference . . .
https://www.mql5.com/en/forum/139964 or https://www.mql5.com/en/forum/117484 and others, use Google . . .
But you can access global arrays without passing them by reference as well.
thanks RaptorUK, "instead pass the array by reference", are you refering to create a global variable - global Double Array???
It doesn't matter if the arrays passed by ref were global or local defined.
But you can access global arrays without passing them by reference as well.
This is work
//+------------------------------------------------------------------+ //| sectionPinbar_v1.mq4 | //| | //| | //+------------------------------------------------------------------+ #property copyright "" #property link "" extern int numSR = 10; extern int timeFrame = PERIOD_D1; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { double SR[]; ArrayResize(SR, numSR); getArraySR (SR, timeFrame); for(int i = 0; i < ArraySize(SR); i++) { Print (SR[i]); } return(0); } //+------------------------------------------------------------------+ void getArraySR (double& SR[], int timeFrame) { for(int i = 0; i < ArraySize(SR); i++) { SR[i] = i; } return (SR); } 2013.12.20 18:54:17 2009.01.02 11:12 sectionPinbar_v1 EURUSD,M1: 9 2013.12.20 18:54:17 2009.01.02 11:12 sectionPinbar_v1 EURUSD,M1: 8 2013.12.20 18:54:17 2009.01.02 11:12 sectionPinbar_v1 EURUSD,M1: 7 2013.12.20 18:54:17 2009.01.02 11:12 sectionPinbar_v1 EURUSD,M1: 6 2013.12.20 18:54:17 2009.01.02 11:12 sectionPinbar_v1 EURUSD,M1: 5 2013.12.20 18:54:17 2009.01.02 11:12 sectionPinbar_v1 EURUSD,M1: 4 2013.12.20 18:54:17 2009.01.02 11:12 sectionPinbar_v1 EURUSD,M1: 3 2013.12.20 18:54:17 2009.01.02 11:12 sectionPinbar_v1 EURUSD,M1: 2 2013.12.20 18:54:17 2009.01.02 11:12 sectionPinbar_v1 EURUSD,M1: 1 2013.12.20 18:54:17 2009.01.02 11:12 sectionPinbar_v1 EURUSD,M1: 0
- 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 guys,
thanks for actively responding my first question, much appreciated.
Here is my second question of the my first day.
I have a function called "double removeDuplicatedOrder()" return a double Array, which contains a list of pending order price in double. The "removeDuplicatedOrder()" will be called and the return value from assinged to another double Array(called newPending_Order) in a function called "void processOrderList()". My problem when the "newPending_Order" gets retrun value from "double removeDuplicatedOrder()", i do a print function, which gives me a "all ZERO" empty list.
i have use "=" and ArrayCopy() to get the value and assinged to "newPending_Order", neither is working well. please help. Thanks in advance.
the follow is my code example: