Join & EARN

FOREX ALGOS { }

Entry Logic

The set of rules or conditions that determine when to open a trade. In an automated Forex strategy, entry logic examines market data (price action, indicators, etc.) and signals a buy or sell order when certain criteria are met. For example, a simple entry rule might be “go long when the 14-period RSI crosses above 30.” Entry logic is typically coded in the strategy’s main event handler (e.g. OnTick() or OnBarUpdate()) and invokes an order-send function when true. MetaTrader (MQL) EAs use functions like OrderSend(); cTrader cBots use methods like ExecuteMarketOrder(); NinjaTrader uses methods like EnterLong() or EnterShort().

  • Definition: Conditions specifying where/why to enter a trade (e.g. indicator thresholds, price patterns). For example, “if the last closed candle breaks above the 50-day SMA and momentum is bullish, place a buy order.”

  • Context: Per a Forex strategy manual, “entry signals… are signals opening a position, which are sent by the entry logic of the strategy”. The entry logic produces a market or pending order when its conditions become true.

  • Example (MQL4/5):

    if(iClose(Symbol(),0,0) > iMA(Symbol(),0,0,50,0,MODE_SMA,PRICE_CLOSE,1))
    {
    OrderSend(Symbol(), OP_BUY, 0.1, Ask, 5, Bid-50*Point, Ask+100*Point, "Buy order", 0, 0, clrGreen);
    }
  • Example (cTrader cAlgo):

    // In OnBar(): if last close > 50-period SMA, buy
    if (Bars.ClosePrices.Last(1) > Indicators.SMA(MarketSeries.Close, 50).Result.LastValue)
    ExecuteMarketOrder(TradeType.Buy, SymbolName, 10000, "MyRobot", stopLossPips:50, takeProfitPips:100);
  • Example (NinjaScript):

    // In OnBarUpdate(): if 14-period RSI crosses above 30, enter long
    if (CrossAbove(RSI(14, 3), 30, 1))
    EnterLong("LongEntry");