Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

MTF Strategy Stop Market Orders Getting Cancelled On Next Bar

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

    MTF Strategy Stop Market Orders Getting Cancelled On Next Bar

    Hello,

    I am developing a strategy where logic is performed on a higher timeframe and then orders placed using the primary series, and running into an issue with historical order processing (on the chart) and back testing (in Strategy Analyzer) which I cannot figure out.

    The strategy adds Daily bars as the second data series and makes it's decisions to trade based on the Daily data. Once an entry is determined, on the close of the first bar of the session of the primary series, the strategy places a Stop Market order.

    What is happening is the system is cancelling the Stop Market order automatically on the close of the next primary series bar. I cannot figure out why. This is happening on all different timeframes, 1m, 5m, 30m, etc

    Attached is a stripped down version of the strategy that can reproduce the behavior.

    Here is some output from the Output Console where I've captured the order updates occurring.

    Code:
    1/18/2023 12:05:00 AM: Entering Long Stop Mkt @ 4028.5, SL = 3996.75, TP = 4024.25. Current Close = 4014.25, High = 4015, Low = 4014
    1/18/2023 12:05:00 AM - Order update: orderId='NT-00000-612' account='Sim101' name='Long' orderState=Submitted instrument='MES 03-23' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=4028.5 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-01-18 00:05:00' gtd='2099-12-01' statementDate='2023-02-20'
    1/18/2023 12:05:00 AM - Order update: orderId='NT-00000-612' account='Sim101' name='Long' orderState=Accepted instrument='MES 03-23' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=4028.5 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-01-18 00:05:00' gtd='2099-12-01' statementDate='2023-02-20'
    1/18/2023 12:05:00 AM - Order update: orderId='NT-00000-612' account='Sim101' name='Long' orderState=Working instrument='MES 03-23' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=4028.5 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-01-18 00:05:00' gtd='2099-12-01' statementDate='2023-02-20'
    1/18/2023 12:10:00 AM - Order update: orderId='NT-00000-612' account='Sim101' name='Long' orderState=CancelPending instrument='MES 03-23' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=4028.5 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-01-18 00:05:00' gtd='2099-12-01' statementDate='2023-02-20'
    1/18/2023 12:10:00 AM - Order update: orderId='NT-00000-612' account='Sim101' name='Long' orderState=CancelSubmitted instrument='MES 03-23' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=4028.5 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-01-18 00:05:00' gtd='2099-12-01' statementDate='2023-02-20'
    1/18/2023 12:10:00 AM - Order update: orderId='NT-00000-612' account='Sim101' name='Long' orderState=Cancelled instrument='MES 03-23' orderAction=Buy orderType='Stop Market' limitPrice=0 stopPrice=4028.5 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-01-18 00:05:00' gtd='2099-12-01' statementDate='2023-02-20'
    
    ​
    And here is a screenshot of the Strategy settings
    Click image for larger version

Name:	image.png
Views:	146
Size:	28.7 KB
ID:	1236142


    Thank you for your assistance!
    -vossom




    #2
    Sorry this should have gone under the NT8 section, not NT7. Can a mod please move it?

    Comment


      #3
      Hello vossom,

      Orders that are not using the isLiveUntilCancelled parameter will have this default to false. This means when the bar closes the order will automatically be cancelled if it is not resubmitted.

      Enable TraceOrders and open the output window and re-run the script. Do you messages about orders being automatically cancelled?


      If so, use the overload with isLiveUntilCancelled with a value of true to keep orders alive, or re-submit them on each new bar.
      EnterLongStopMarket(int barsInProgressIndex, bool isLiveUntilCancelled, int quantity, double stopPrice, string signalName)




      I am also including a link to a forum post about 1-tick intra-bar granularity for order fill accuracy.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Thank you, setting isLiveUntilCancelled solved the problem. Excellent support thank you!!!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by usazencort, Today, 01:16 AM
        0 responses
        1 view
        0 likes
        Last Post usazencort  
        Started by kaywai, 09-01-2023, 08:44 PM
        5 responses
        603 views
        0 likes
        Last Post NinjaTrader_Jason  
        Started by xiinteractive, 04-09-2024, 08:08 AM
        6 responses
        22 views
        0 likes
        Last Post xiinteractive  
        Started by Pattontje, Yesterday, 02:10 PM
        2 responses
        21 views
        0 likes
        Last Post Pattontje  
        Started by flybuzz, 04-21-2024, 04:07 PM
        17 responses
        230 views
        0 likes
        Last Post TradingLoss  
        Working...
        X