coding issue

 

how do i write in code :

if (order is closed) {open this order} else {open this order} else {this 3rd order}? without numbering the orders, i just need it to be simple so that if a certain pending order has been placed it doesnt get placed again until it reaches a tp or a sl. thanks

 
nayef wrote >>

how do i write in code :

if (order is closed) {open this order} else {open this order} else {this 3rd order}? without numbering the orders, i just need it to be simple so that if a certain pending order has been placed it doesnt get placed again until it reaches a tp or a sl. thanks

You need to loop throw the open orders and count what you need, for exmaple all open buystops. If you need to look if an order is already closed then you have to loop throw the orders history. Are lot of examples if you use the search function
 

ok but i need to make sure that each order is only opened once, the layout of the script is very specific to what the ask or bid price is so theres over 50 pending orders in the script all followed by each other like so:


OrderSend(Symbol(),OP_SELL,Lots,86.200,3,86.200+StopLoss*Point,86.200-TakeProfit*Point,"sell",0,CLR_NONE);

OrderSend(Symbol(),OP_SELL,Lots,86.250,3,86.250+StopLoss*Point,86.250-TakeProfit*Point,"sell",0,CLR_NONE); 

OrderSend(Symbol(),OP_SELL,Lots,86.300,3,86.300+StopLoss*Point,86.300-TakeProfit*Point,"sell",0,CLR_NONE); 

OrderSend(Symbol(),OP_SELL,Lots,86.350,3,86.350+StopLoss*Point,86.350-TakeProfit*Point,"sell",0,CLR_NONE); 

OrderSend(Symbol(),OP_SELL,Lots,86.400,3,86.400+StopLoss*Point,86.400-TakeProfit*Point,"sell",0,CLR_NONE); 


therefore i probably will need an "if" and "else" command maybe something like


if (orderstotal()>1) {OrderSend(Symbol(),OP_SELL,Lots,86.200,3,86.200+StopLoss*Point,86.200-TakeProfit*Point,"sell",0,CLR_NONE);} else { next op_sell} else { next op_sell) 


however that doesnt seem to work because it will only excute 1 order until its fulfilled and thats not what i need... i need it to open just the order itself once until its fulfilled and continue with the rest of the orders in the script in the same way (opening them once each until they are closed). thats why i dont think magic numbers would work here because its all one script.