Place an order if no order exists
Here is a sample code you can use
int MAGICMA = 0; // set this to your magic
for (int x_ORDER = 0; x_ORDER < OrdersTotal(); x_ORDER++) // loop all orders
{
if (OrderSelect(x_ORDER, SELECT_BY_POS, MODE_TRADES) )
{
if (OrderSymbol() == Symbol () && OrderMagicNumber () == ( MAGICMA ) ) // this will check so will only work on orders of the same symbol and magic number
{
if (OrderType() <= OP_SELL)return (1); // if this is true you have a open oder for this pair with this magic number
}
}
}
Thanks you - will give it a try!
Hello Folks.
I'm pretty sure that this is explained somewhere, but I guess I'm not using the right search terms.
My question:
How do I tell an EA to only place an order if no other one is currently placed?
To get a bit more specific: I want to place a BUYSTOP, only of no other BUYSTOP or BUY-Order exists.
Can anybody please help me out here?
Thanks in advance.
WorstCases