Tarea técnica
As you can see from the EA I have attached. The stop moves to breakeven + 5pips when the price moves in the direction of profit by 7 pips + 5 pips. The issue with this stop is it moves from entry price(openorderprice) due to slippage sometimes entry price is not always candlestick open(which is when the trade is supposed to open.
I want the code changed so that breakeven stoploss to be set from candlestick open.
he stoploss code I am using at the moment is shown below.
void TrailingStopBE(int type, double profit, double add) //set Stop Loss to open price if in profit
{
int total = OrdersTotal();
profit = NormalizeDouble(profit, Digits());
for(int i = total-1; i >= 0; i--)
{
while(IsTradeContextBusy()) Sleep(100);
if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue;
if(OrderMagicNumber() != MagicNumber || OrderSymbol() != Symbol() || OrderType() != type) continue;
RefreshRates();
if((type == OP_BUY && Bid > OrderOpenPrice() + profit && (NormalizeDouble(OrderStopLoss(), Digits()) <= 0 || OrderOpenPrice() > OrderStopLoss()))
|| (type == OP_SELL && Ask < OrderOpenPrice() - profit && (NormalizeDouble(OrderStopLoss(), Digits()) <= 0 || OrderOpenPrice() < OrderStopLoss())))
myOrderModify(OrderTicket(), OrderOpenPrice() + add, 0);
TrailingStopBE(OP_BUY, 70 * myPoint, 0 + 50 * myPoint); //Trailing Stop = go break even + fixed value
TrailingStopBE(OP_SELL, 70 * myPoint, 0 - 50 * myPoint); //Trailing Stop = go break even - fixed value