Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Historical trades not taking SL TP limit orders using exitlimit() method

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Historical trades not taking SL TP limit orders using exitlimit() method

    I am using the below to set my TP and SL levels. But when i load the historical trades, none of these orders are taken even though during market replay i do see they are set and triggered. Is this normal?

    if (execution.MarketPosition == MarketPosition.Short)
    {
    ExitShortLimit(execution.Quantity, true, 1, takeProfitShortLevels, "TP_" + execution.Order.Name, execution.Order.Name);
    ExitShortStopLimit(execution.Quantity, true, 1, execution.Price + InitialSLAmount, execution.Price + InitialSLAmount, "Initial_Short_SL_" + i, execution.Order.Name);
    }
    // Handle long position TP and SL
    else if (execution.MarketPosition == MarketPosition.Long)
    {
    ExitLongLimit(1, true, execution.Quantity, takeProfitLongLevels, "TP_" + execution.Order.Name, execution.Order.Name);
    ExitLongStopLimit(1, true, execution.Quantity, execution.Price - InitialSLAmount, execution.Price - InitialSLAmount, "Initial_Long_SL_" + i, execution.Order.Name);
    }​

    #2
    Hello sofortune,

    It appears you are providing the quantity of the execution as the barsInProgressIndex.

    EnterShortLimit(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double limitPrice, string signalName)

    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Oh geez, thanks. Not sure what happened there. Let me check if that fixes the issue.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      45 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      21 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      31 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      50 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      42 views
      0 likes
      Last Post CarlTrading  
      Working...
      X