Check the comment field.
It seems that comment can only be set in OrderSend, if I use OrderSelect, how can I choose comment I've set through OrderSelect?
Select an order, and OrderComment() will return the comment string.
Observe what you get for orders closed with TP or SL.
I set comment with OrderSend and add Alert(OrderComment()) after every OrderClose and OrderModify, and found that there were always the origianl comment I set shown. Could you give me more details? Thanks again.
All the ordens closed by SL and TP will have an [sl] or [tp] added to you comment. Sometimes I see in my account also [tp/a] and [sl/a] and I dont know yet what it means :)
hope it helps
All the ordens closed by SL and TP will have an [sl] or [tp] added to you comment. Sometimes I see in my account also [tp/a] and [sl/a] and I dont know yet what it means :)
hope it helps
There are still no result. I think i didn't put the Alert(OrderComment()) at a proper position. When StopLoss happened, there are no messages shown. Where should I put the Alert(OrderComment()) sentence?
To tell what trades were closed by SL or TP, you need to scan through the closed ( historical ) orders, select each one, and query for the comment.
Another method might be to compare the closing price to the stoploss or takeprofit settings, but that might be affected by slippage (?)
for(int i = OrdersHistoryTotal()-1; i >=0; i--){ OrderSelect(i, SEL_BY_POS, MODE_HISTORY); if(StringFind(OrderComment(), "[tp", 0) >= 0){ ... you found one, do something... } if(StringFind(OrderComment(), "[sl", 0) >= 0){ ... you found one, do something... } }
To tell what trades were closed by SL or TP, you need to scan through the closed ( historical ) orders, select each one, and query for the comment.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
How to caculate how many orders are closed by StopLoss or TakeProfit?
I can use OrderClose to know how many orders or closed normally, but the order closed by StopLoss or TakeProfit can't be known through OrderClose.
Thanks.