Hello Everyone,
Would someone know if it is possible to check the closing criteria of two open orders at the same time before closing them both together?
I verified this code closes the buy and sell orders in profit or loss one at a time, but when trying to verify both open orders meet the criteria at the same time it is not closing either one. Does anyone have a suggestion of what is missing?
if (ExecuteClose1)
{
ForLoop1 = 0;
double OOP = OrderOpenPrice();
for(ForLoop1 = OrdersTotal()-1; ForLoop1 >= 0 ; ForLoop1--)
if(OrderSelect(ForLoop1, SELECT_BY_POS) && (OrderMagicNumber() == MagicNumber) && (OrderSymbol() == Symbol()))
{
if (((OrderType() == OP_BUY) && (Bid >= OOP + MinimumDistance * Point) || (Bid <= OOP - MinimumDistance * Point))
&& ((OrderType() == OP_SELL) && (Ask <= OOP - MinimumDistance * Point) || (Ask >= OOP + MinimumDistance * Point)))
{
CloseAllOpenTrades();
}
}
}
Would someone know if it is possible to check the closing criteria of two open orders at the same time before closing them both together?
I verified this code closes the buy and sell orders in profit or loss one at a time, but when trying to verify both open orders meet the criteria at the same time it is not closing either one. Does anyone have a suggestion of what is missing?
if (ExecuteClose1)
{
ForLoop1 = 0;
double OOP = OrderOpenPrice();
for(ForLoop1 = OrdersTotal()-1; ForLoop1 >= 0 ; ForLoop1--)
if(OrderSelect(ForLoop1, SELECT_BY_POS) && (OrderMagicNumber() == MagicNumber) && (OrderSymbol() == Symbol()))
{
if (((OrderType() == OP_BUY) && (Bid >= OOP + MinimumDistance * Point) || (Bid <= OOP - MinimumDistance * Point))
&& ((OrderType() == OP_SELL) && (Ask <= OOP - MinimumDistance * Point) || (Ask >= OOP + MinimumDistance * Point)))
{
CloseAllOpenTrades();
}
}
}