Join & EARN

FOREX ALGOS { }

Break-Even Logic

A specific risk rule to move the stop-loss to the entry price once the trade has reached a specified profit (thus guaranteeing no loss). For example, “after 30 pips in profit, set stop-loss to entry.” This can be implemented by checking profit and, if reached, modifying the order.

  • Example (MQL4):

    if(PositionSelect(Symbol()) && PositionGetDouble(POSITION_PROFIT) >= 30*SymbolInfoDouble(_Symbol, SYMBOL_POINT))
    {
    double entry = PositionGetDouble(POSITION_PRICE_OPEN);
    double sl = entry; // move stop to break-even
    OrderModify(PositionGetInteger(POSITION_TICKET), entry, sl, 0);
    }