Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetProfitTarget and SetStopLoss on Multi-Instrument strategy

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

    SetProfitTarget and SetStopLoss on Multi-Instrument strategy

    Dear NinjaTrader Support Team,

    I am encountering issues with the functionality of SetProfitTarget and SetStopLoss in a Multi-Instrument strategy while using the Strategy Analyzer. Below are the details of the issues I am facing:
    1. Stop Loss Triggered Incorrectly:
      • As shown in the attached screenshot, the Stop Loss for AAPL was triggered at the same time as the original position entry on January 3, 2022.
      • Upon reviewing the daily high and low for AAPL on that day, the price levels were well above the Stop Loss. This behavior seems incorrect, as the Stop Loss should not have been activated under these conditions. Print screen attached is daily to get an overview of the day but the strategy is run on a minute historical data (I confirm that the prices stay in the daily overview range)
      • From a configuration perspective, the Stop Loss and Profit Target values appear to be set correctly for each stock orders.
    2. OCO ID Misalignment:
      • Initially, the OCO IDs for the orders seem to be correctly aligned with the long entry ID.
      • However, starting the next day, the OCO IDs no longer appear to match or behave as expected.
      • I might not fully understand how OCO IDs are supposed to function in this context, but this discrepancy seems unusual.

    Configuration Details:
    • Both SetProfitTarget and SetStopLoss are configured once in the State.Configure state.
    • No specific "entry signal" is provided to these methods, which, as per my understanding, should apply to all relevant orders.

    Could you please help me understand if there is an issue with my implementation. Any guidance or clarification you can provide on the correct usage of SetProfitTarget and SetStopLoss in Multi-Instrument strategies would be greatly appreciated.

    Thank you for your support, and please let me know if you need additional information or files to troubleshoot this further.

    Best regards,
    Last edited by Logicwar; 01-05-2025, 10:43 AM.

    #2
    Is anyone else experiencing the same behavior?

    Comment


      #3
      Hello Logicwar,

      There are unknowns here.

      Set methods update with the primary instrument series only and cannot specify a barsInProgressIndex (so will not work intra-bar granularity).

      The help guide has a mention of this:
      "Should you have multiple Bars objects of the same instrument while using SetStopLoss() in your strategy, you should only submit orders for this instrument to the first Bars context of that instrument. This is to ensure your order logic is processed correctly and any necessary order amendments are done properly."
      Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.



      The behavior of historical or real-time will be different.

      In historical intra-bar granularity must be implemented to have intra-bar fills. Otherwise the entire bar is processed at once. Set methods that are within the high and low of the entry bar will be filled at the same time.

      Implement 1-tick intra-bar granularity (for each instrument) for accurate price and time intra-bar fills.



      The OCO must be unique and the stop and target must be using the same OCO string. If an order is submitted in historical the way the string generated may change, however the stop and target should still be using the same OCO string. As long as it's unique and the stop and target are using the same string, it is working correctly.


      Chelsea B.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, Today, 05:17 AM
      0 responses
      38 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      124 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      64 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      41 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      46 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X