magic numbers and closing orders

 
When opening multiple positions, I know I have to use unique magic numbers in the OrderSend() function for each position.  However, when conditions arise to close one particular position, do I have to make reference to the magic number assigned to that one particular position or is just referencing that position by its ticket number, OrderSelect(ticket, SELECT_BY_TICKET), sufficient?
 
forestmyopia:
When opening multiple positions, I know I have to use unique magic numbers in the OrderSend() function for each position. 
Why do you have to ?
 
Use if( OrderSelect(...) ). You don't need a magic#. I don't even need the  OrderSelect(). It just help provide information you need for OrderClose() if you don't already have it. Also helps in verifying that the order is not already closed. 
 
RaptorUK:
Why do you have to ?

  When opening multiple positions simultaneously, my understanding is that you have to provide magic numbers for each position or the system will get confused.  But, it seems that referencing a position by its ticket number is all you need to close that position. Is that correct?

 
forestmyopia:

  When opening multiple positions simultaneously, my understanding is that you have to provide magic numbers for each position or the system will get confused.  But, it seems that referencing a position by its ticket number is all you need to close that position. Is that correct?

 

 


opening multiple positions

how many numbers can ticket be ??

so you close that ticket  but how do you remember all

 
forestmyopia:

  When opening multiple positions simultaneously, my understanding is that you have to provide magic numbers for each position or the system will get confused.  But, it seems that referencing a position by its ticket number is all you need to close that position. Is that correct?

Magic Numbers are for your benefit,  as the coder,  not the system as such.  The ticket number is indeed unique and you can select the Order just by it's ticket number . . .  what else is unique about your orders ?  lot size ? anything else ?
 
  1. Use a range Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 forum
  2. Don't open multiple orders, do a partial close and differentiate SL < open (original,) SL = open (first partial close,) SL > open (second partial close)
 
RaptorUK:
Magic Numbers are for your benefit,  as the coder,  not the system as such.  The ticket number is indeed unique and you can select the Order just by it's ticket number . . .  what else is unique about your orders ?  lot size ? anything else ?

Yes, lot size could vary.  For example, I could open a trade for eurusd at .1 lots and simultaneously open a trade for eurjpy at 2 lots.  Also, I can have different stoploss and takeprofit levels for each.

But, I think my question has been answered.  Supplying the ticket number is all I need to identify which trade to close.  Thanks.

Reason: