Job finished
Specification
Hello
I need to add the following condition to my existing EA TrailingStop.
Condition: proceed TrailingStop only if all order in the same currency pair only have BUY or SELL.
Example: if open order EURUSD consisting of BUY and SELL, do not proceed.
Proceed only if EURUSD either BUY only or SELL only, not both.
I will send you my existing EA once we agree on the work.
Existing Code below.
//+------------------------------------------------------------------+
//| Trailing STOP |
//+------------------------------------------------------------------+
void TrailPositions()
{
int cnt = OrdersTotal();
for (int i=0; i<cnt; i++)
{
if (!(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))) continue;
if (OrderSymbol() != Symbol()) continue;
if (OrderMagicNumber() != Magic) continue;
if (OrderType() == OP_BUY)
{
if (Bid-OrderOpenPrice() > StartProfit*Point)
{
if (OrderStopLoss() < Bid-TrailingStop*Point)
{
OrderModify(OrderTicket(), OrderOpenPrice(), Bid-TrailingStop*Point, OrderTakeProfit(), 0, clModify);
}
}
}
if (OrderType() == OP_SELL)
{
if (OrderOpenPrice()-Ask > StartProfit*Point)
{
if (OrderStopLoss() > Ask+TrailingStop*Point || OrderStopLoss() == 0)
{
OrderModify(OrderTicket(), OrderOpenPrice(), Ask+TrailingStop*Point, OrderTakeProfit(), 0, clModify);
}
}
}
}
}