R
You can get at closed Order info using the code demonstrated here 'Last trade profit/loss?'
The last closed order can be located by the highest OrderTicket() (within History) or the latest OrderCloseTime()
Good Luck
-BB-
R
You can get at closed Order info using the code demonstrated here 'Last trade profit/loss?'
The last closed order can be located by the highest OrderTicket() (within History) or the latest OrderCloseTime()
Good Luck
-BB-
Isn't there a problem in this code from the reference you gave? The problem is in order select that instead of
OrderSelect(OrdersHistoryTotal()-1, Select_by_pos,MODE_HISTORY);
it should be:
OrderSelect(i, Select_by_pos,MODE_HISTORY);
Why doing a cycle "for" if the same order (the last one) is selected in all interations? It has no sense.
Additionally, inside the "for cycle" instead of commas, there should be semi-colons.
In the "iff" statements, in order to descriminate profit/loss shouldn't it by like this?
if(OrderType()==OP_BUY && OrderClosePrice()>=OrderOpenPrice()) last="profit";
The corrected code from the reference is:
/***** the right code****/ string last; for(int i=OrdersHistoryTotal()-1;i>=0;i--) { OrderSelect(i, SELECT_BY_POS,MODE_HISTORY); //error was here if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic) { //for buy order if(OrderType()==OP_BUY && OrderClosePrice()>=OrderOpenPrice()) last="profit"; if(OrderType()==OP_BUY && OrderClosePrice()<=OrderOpenPrice()) last="loss"; } }
- 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!
After I start my EA, I would like to monitor the open orders with it. If some of them takes profit, I would like the EA to reopen it with the same parameters.
So I have to ask information from the last closed order in the Account History.
How can I get hese information? Which function can I use? Please give me advice!
Thank you.
Relative