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

Back to topics list To post a new topic, please log in or register
avatar
6
konradp 2016.04.26 12:14
 

Hi,


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

avatar
Moderator
3418
GumRai 2016.04.26 12:18 #
 
Loop through the open orders and check OrderMagicNumber()
avatar
6
konradp 2016.04.26 12:27 #
 
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.
avatar
6
konradp 2016.04.26 12:29 #
 
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
avatar
6
konradp 2016.04.26 12:33 #
 
sugar... but how will I zero it if there is no orders....
avatar
Moderator
3418
GumRai 2016.04.26 12:36 #
 
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
avatar
12998
WHRoeder 2016.04.26 14:38 #
 
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
Back to topics list  

To add comments, please log in or register