// retrieving info from trade history int hstTotal=OrdersHistoryTotal(); double Acc[hstTotal+1]; Acc[0] = AccountBalance(); for(int i=1;i<=hstTotal;i++) { //---- check selection result if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)==false) break; else { //order is allready selected no need to select it again Acc[i]= Acc[i-1]+ OrderProfit( ) ; } }
Thanks a lot,
but if you test it, will find it doesn't work better.
In fact, after a ArraySetAsSeries( Acc, true), here what happens.
If my last 3 balance values are: 9119.56, 9052.15, 9350.71, Acc[0] returns correctly 9119.56, but Acc[1] returns 9148.46, Acc[2] 9158.09, Acc[3] 9196.62.
I do not know how and where returns figures so different, they could be from the Balance of trades not closed yet.
Fixing that with
OrderSelect(i,SELECT_BY_TICKET,MODE_TRADES)
nothing better again, remains only the zero-index as different from zero and correct, the others element of the array seem to be all zeros.
Perhaps, It's only a my erroneous impression due to erroneous inferences by printing. With this code, in fact, moving averages seem to work:
// retrieving info from trade history int hstTotal=OrdersHistoryTotal(); double Acc[2000]; Acc[0] = AccountBalance(); for(int i=1;i<=hstTotal;i++) { //---- check selection result if(OrderSelect(i,SELECT_BY_TICKET,MODE_TRADES)==false) break; else { //order is already selected no need to select it again Acc[i]= Acc[i-1]+ OrderProfit( ) ; } }
//followed by.... ArraySetAsSeries( Acc, true);
The fact is I do not still have the 100% of certainty.
Help...
SA
It is the same you just get the array from first to last indexed...try
for(int i=hstTotal;i>=0;i--) { ......
- 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 everybody,
My questione is simple but I struggled enough with the implicit recoursivity of processing every tick. I need to create an array containing for every indexes my different values of AccountBalance as they appears to be in the backtesting window. In order to calculate some moving averages of it, with iMAOnArray method.
Ok. Acc[0] is correct, but if I print Acc[1] or previous I do not obtain the previos AccountBalance value.Thanks a lot,
SA