Probably because your array is not big enough, the array index you're trying to use could be way up there if you have a lot of closed orders in the history, or if you have no orders in the history you would be trying to use array index of -1 which would also not work.
double TS[]; int x1=OrdersHistoryTotal()-1; ArrayResize(TS,x1+1); TS[x1]=11; Alert ("TS X1 = ",TS[x1]); Alert ("OrdersHistoryTotal = ",OrdersHistoryTotal());
double x1=OrdersHistoryTotal()-1;
TS[x1]=11;
- Make sure you know the problems with history Could EA Really Live By Order_History Alone? - MQL4 forum especially note Order History sort by closing date - MQL4 forum for resizing the arrays.
You also should not index an array with a double. Use an int.
Since I know you are a competent programmer this answer has stumped me. Did you mean that you can't use an int to set the size of an array, as in
I think WHR means you can't use a double . . . if you try to it won't compile.
'[' - array index is to be an integer
I think WHR means you can't use a double . . . if you try to it won't compile.
'[' - array index is to be an integer
Yes, I just tried it :-)
Thanks.
Sometimes WHR is so terse it's almost impossible to decipher. I read it as you couldn't use an int as an index, as did SDC.
So, the OP's code didn't even compile? He must have re-typed it wrong rather than copy/paste.
x1=3;//OrdersHistoryTotal()-1; TS[x1]={11};//TrailingStop; Alert ("TS X1 = "+TS[x1]);
I should be getting 11 on Alert output
Yes, I just tried it :-)
Sometimes WHR is so terse it's almost impossible to decipher. I read it as you couldn't use an int as an index, as did SDC.double idx = ... double val = Array[idx];
And it wouldn't compile; said something like array index must be an integer.
Perhaps my comment is no long true.
Ok, So I've lost the OrdersHistoryTotal(); … but still getting 0 on Alert ouput. Am missing something really basic…
I should be getting 11 on Alert output
How are you declaring the array ? are you using ArrayResize ? you can't just do this . . .
double TS[];
you can do this . . .
double TS[29];
. . . or this . . .
double TS[]; ArrayResize(TS, 28);
- 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 There
I'm having major difficulties with certain arrays in mql4...
double x1=OrdersHistoryTotal()-1;
TS[x1]=11;
Alert ("TS X1 = "+TS[x1]);
…but the output produces: "Alert: TS X1 = 0.00000000"
Why?