How to check is there any order open with certain Magic Number

 

Hi,


I have a few orders open for different currencies, how can I find is there an open order for certain Magic Number?

 
Loop through the open orders and check OrderMagicNumber()
 
yes, but if I setup something like if (OrderMagicNumber() =MagicNUmber){orderopen=1}else{orderopen=0} then it will return 0 every time it scan order different to one i'm looking for, what I need is more like to check is any order open for MagicNumber.
 
ok I think i have solution, I will scan orders and add orderopen together for entire scan, at the end if I get value <0 it mean there is some order open
 
sugar... but how will I zero it if there is no orders....
 
If you want to count the orders, set a counter to zero before the loop then add 1 everytime an order with the magic number is detected
 
konradp if I setup something like if (OrderMagicNumber() =MagicNUmber){orderopen=1}else{orderopen=0} then it will return 0 every time it scan order different to one i'm looking for, what I need is more like to check is any order open for MagicNumber.
  1. else{orderopen=0} means it's zero if the first order is not the MN (rest of the orders are irrelevant.) Set it zero before the loop, and you'll set it to 1 if any orders exist (in any position.)
  2. Don't use 0 and 1 when you mean boolean.
    This is why I say: You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So Don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled. Long_Entry sounds like a trigger price or a ticket number and "if long entry" is an incomplete sentence.
  3. OrderSelect loop see. Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 forum
Reason: