Hi All,
First, I am looking for a script (or existing code) that provides the basic structure for the following:
Close pending order such that when using a breakout strategy (i.e., BuyStop & SellStop are executed) will delete the remaining pending order after one goes live?
If OP_BUYSTOP becomes OP_BUY then OP_SELLSTOP is deleted or
If OP_SELLSTOP becomes OP_SELL then OP_BUYSTOP is deleted.
If this exists, please post or direct to download thread.
Absent this, I submit the following attempt to code this myself:
if(DelOppPO)
{
int totals = OrdersTotal();
for(int r = totals - 1; r >= 0; r--)
{
if(OrderSelect(r, SELECT_BY_POS) && OrderSymbol() == Symbol())
{
if(OrderType() == OP_BUY) Buy = OP_BUY;
{
if(OrderType() == OP_BUYSTOP) BuyStop = OP_BUYSTOP;
{
if(OrderType() == OP_SELL) Sell = OP_SELL;
{
if(OrderType() == OP_SELLSTOP) SellStop = OP_SELLSTOP;
{
if(OrderType() == Buy && OrderType() == SellStop)
{
if(OrderType() == SellStop) OrderDelete(OrderTicket());
if(OrderType() == Sell && OrderType() == BuyStop)
{
if(OrderType() == BuyStop) OrderDelete(OrderTicket());
}
}
}
}
}
}
}
}
}
First problem: In the for statement, r value never changes from -1 & second: will the code, as listed, close the remaining pending order after the other goes live?
Thanks in advance!
First, I am looking for a script (or existing code) that provides the basic structure for the following:
Close pending order such that when using a breakout strategy (i.e., BuyStop & SellStop are executed) will delete the remaining pending order after one goes live?
If OP_BUYSTOP becomes OP_BUY then OP_SELLSTOP is deleted or
If OP_SELLSTOP becomes OP_SELL then OP_BUYSTOP is deleted.
If this exists, please post or direct to download thread.
Absent this, I submit the following attempt to code this myself:
if(DelOppPO)
{
int totals = OrdersTotal();
for(int r = totals - 1; r >= 0; r--)
{
if(OrderSelect(r, SELECT_BY_POS) && OrderSymbol() == Symbol())
{
if(OrderType() == OP_BUY) Buy = OP_BUY;
{
if(OrderType() == OP_BUYSTOP) BuyStop = OP_BUYSTOP;
{
if(OrderType() == OP_SELL) Sell = OP_SELL;
{
if(OrderType() == OP_SELLSTOP) SellStop = OP_SELLSTOP;
{
if(OrderType() == Buy && OrderType() == SellStop)
{
if(OrderType() == SellStop) OrderDelete(OrderTicket());
if(OrderType() == Sell && OrderType() == BuyStop)
{
if(OrderType() == BuyStop) OrderDelete(OrderTicket());
}
}
}
}
}
}
}
}
}
First problem: In the for statement, r value never changes from -1 & second: will the code, as listed, close the remaining pending order after the other goes live?
Thanks in advance!