Join & EARN

FOREX ALGOS { }

Take-Profit Logic

The rules for setting take-profit orders. Similar to stop-loss logic, take-profit logic determines at what price to automatically close a winning trade. This could be a fixed profit target (e.g. 2:1 reward:risk), a trailing take-profit, or other exit algorithms. In NinjaScript, SetProfitTarget() works in tandem with SetStopLoss().

  • Definition: Rules for the profit exit. E.g. “exit with a 100-pip profit” or “close half position at 1:1 RR and rest at 2:1”.

  • Context: Implemented by specifying a profit target price or sending a limit order. In MQL, provide the TP price to OrderSend(). In cAlgo, provide takeProfitPips. In NinjaScript, use SetProfitTarget().

  • Example (MQL4):

    double tp = Ask + 100*Point;
    OrderSend(Symbol(), OP_BUY, 0.1, Ask, 5, 0, tp, "Buy w/TP", 0, 0, clrBlue);
  • Example (cAlgo):

    ExecuteMarketOrder(TradeType.Sell, SymbolName, 50000, "Bot", stopLossPips:50, takeProfitPips:150);
  • Example (NinjaScript):

    SetProfitTarget(CalculationMode.Ticks, 50);