Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Loss and Take Profit Orders for second instrument cancelled by Ninja Trader.

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

    Stop Loss and Take Profit Orders for second instrument cancelled by Ninja Trader.

    Hi,
    We are backtesting one Strategy in which we want to trade more than one stock, and we are facing the following issue:
    1) --> The Strategy enters Long in stock 1 (LMFA) on the following instant: 26/01/2018 14:30:00 CurrentBar: 2 BarsInProgress: 0 Instrument: LMFA
    When we receive information that entry order was executed, we set the stop loss and take profit orders and we link both to the entry order (EnterLongLMFA2)
    2) --> The Stop Loss is activated for LMFA stock and Profit Target is cancelled. So far this behaviour is OK.
    3) --> The Strategy tries to enter Long in the second stock (MNKD) on the following instant: 26/01/2018 14:30:00 CurrentBar: 1 BarsInProgress: 1 Instrument: MNKD
    So far this behaviour is OK.
    When we receive confirmation that entry order was executed we set the Stop Loss and Take Profit orders and we tie them to the second stock entry order
    (EnterLongMNKD1). The platform INCORRECTLY links both orders to the previous Take Profit Order of the first stock (LMFA), already cancelled (oco='NT-00002-107').
    4) --> Having an open Long Position in MNKD, the strategy detects that it's time to open a Short Position on the first stock (LMFA) and opens it successfully. At this
    time we have two open positions: Long MNKD and Short LMFA.
    5) --> On next MNKD Bar (26/01/2018 14:30:00 CurrentBar: 2 BarsInProgress: 1 Instrument: MNKD), MNKD Stop Loss and Take Profit Orders are cancelled, causing position on this stock to be open until the end of the session.

    Could you help us to solve this issue?
    Kind Regards.

    #2
    Hello Joaquim Cipriano,

    Thanks for your inquiry.

    It sounds like the root of many of these issues has to do with incorrectly calling SetProfitTarget() and SetStopLoss() after you have entered, when these Set methods should be fired before the entry to prep NinjaTrader to automatically place these protective orders.

    From the help guide:
    • Should you call this method to dynamically change the stop loss price in the strategy OnBarUpdate() method, you should always reset the stop loss price / offset value when your strategy is flat otherwise, the last price/offset value set will be used to generate your stop loss order on your next open position
    I may suggest reviewing the documentation on these order methods and if you are working with a Multi Series NinjaScript strategy, I would recommend using your own Exit() methods with the overloads to set the order on a specific BarsInProgress to tie it to your desired data series' instead of the Set methods. I would also suggest looking into using Order objects from the Advanced Order Handling rules to further manage these positions.

    I'll include documentation on the items discussed and other Order Handling Rules that should be minded in the Managed Approach.

    Advanced Order Handling (Multi Series rules) - https://ninjatrader.com/support/help...rumentStrategy

    Managed Approach Internal Order Handling Rules - https://ninjatrader.com/support/help...antedPositions

    Multi Series NinjaScript reference - https://ninjatrader.com/support/help...nstruments.htm

    SampleOnOrderUpdate (Order object example) - https://ninjatrader.com/support/foru...ead.php?t=7499

    Please let us know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by algospoke, Yesterday, 06:40 PM
    2 responses
    19 views
    0 likes
    Last Post algospoke  
    Started by ghoul, Today, 06:02 PM
    3 responses
    14 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by jeronymite, 04-12-2024, 04:26 PM
    3 responses
    45 views
    0 likes
    Last Post jeronymite  
    Started by Barry Milan, Yesterday, 10:35 PM
    7 responses
    20 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by AttiM, 02-14-2024, 05:20 PM
    10 responses
    181 views
    0 likes
    Last Post jeronymite  
    Working...
    X