OrderComment() as an identifier?

 
Hello,

Usually we use OrderMagicNumber() to identify whether the active order opened by given EA or not. Can we always use always OrderComment() for this purpose?

Thanks
 

System modifies the comment on some positions when closed

 
I see, so we still can use it on active order?
 
In my opinion yes... According to phy's info you should comment content tests provide using https://docs.mql4.com/strings/StringFind function.
 
devilian1899:
I see, so we still can use it on active order?
Beware... if you take partial take profit where lots value is less than OrderLots() the terminal will 100% close your order --> reopen new order with new ticket# for the remaining lots.
Magic# gets assigned to this new order - but your comment will not contain what you put there on OrderSend()

Note that I'm only expanding on what phy rightly stated originally...


fred GBPUSD,H1: deinit() called, "done"=1
fred GBPUSD,H1: <EAprint> after final Close of remaining Lots: OrderLots()=1, and expect EMPTY ticket#: getTicket(magic#123)=-1, and expect zero orders in terminal: OrdersTotal()=0
fred GBPUSD,H1: close #3 buy 1.00 GBPUSD at 2.0086 sl: 2.0061 tp: 2.0111 at price 2.0083
fred GBPUSD,H1: <EAprint> after 2*1Lots PartialTakeProfitCloses, Ticket=#3, OrderComment()="split from #2", Magic=123, OrdersTotal()=1
fred GBPUSD,H1: <EAprint> getTicket(123) OrdersTotal()=1, Ticket=#3, Magic=123
fred GBPUSD,H1: close #2 buy 1.00 GBPUSD at 2.0086 sl: 2.0061 tp: 2.0111 at price 2.0083
fred GBPUSD,H1: <EAprint> after 1*1Lot PartialTakeProfitCloses, Ticket=#2, OrderComment()="split from #1", Magic=123, OrdersTotal()=1
fred GBPUSD,H1: <EAprint> getTicket(123) OrdersTotal()=1, Ticket=#2, Magic=123
fred GBPUSD,H1: close #1 buy 1.00 GBPUSD at 2.0086 sl: 2.0061 tp: 2.0111 at price 2.0083
fred GBPUSD,H1: <EAprint> origOrderTicket #1, OrderComment()="OrderSend Opens 3Lots", Magic=123, OrdersTotal()=1
fred GBPUSD,H1: open #1 buy 3.00 GBPUSD at 2.0086 sl: 2.0061 tp: 2.0111 ok
fred GBPUSD,H1: start() called, "done"=0
fred GBPUSD,H1: init() called, "done"=0
fred started for testing
fred GBPUSD,H1: loaded successfully

 

There you have it.

Reason: