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

Strategy Analyzer order of events...

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

    Strategy Analyzer order of events...

    I believe this is a common problem for the Strategy Analyzer but want to clarify exactly how NT handles things in an attempt to better understand this issue.

    Let's say I look for a simple candlestick pattern and want to place a stop or limit order as soon as the pattern presents itself.

    I can only know the pattern exists as soon as the bar closes, thus lets assume the following:

    Code:
    Using an indicator with a custom DataSeries for signals
    Using Calculate.OnEachTick 
    
    Bar 1 - Pattern forms
    Bar 2 (IsFirstTickOfBar) - Indicator identifies pattern and places it in custom DataSeries Signals[0].
    Bar 2 - Strategy reads Signals[0] and places a Buy Stop Order
    
    ....
    Now this is where things go wrong. I would expect that since this code was run on the first tick of bar 2 and a buy stop order was placed that the bars OHLC values would be used to determine an entry in the strategy analyzer?

    What is happening is the entries always happen on the next bar. So does this mean that Bar 2 the order is being placed but NT does not "fill" it or process the bar values until the next bar?

    Not sure if this is clear, I can provide an image if necessary.

    #2
    Hello fxRichard,

    Thank you for your post.

    From what you describe the order would be submitted on the bar following the confirmation bar. So once the signal is confirmed as valid the execution will occur on the following bar.
    In backtesting the executions will occur on the bar after the condition was found as true. Backtesting will calculate condition on the close of the bar.

    For information on the differences between historical and real-time executions please visit the following link: http://ninjatrader.com/support/helpG...ime_vs_bac.htm

    Please let me know if you have any questions.

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      Hello fxRichard,

      Thank you for your post.

      From what you describe the order would be submitted on the bar following the confirmation bar. So once the signal is confirmed as valid the execution will occur on the following bar.
      In backtesting the executions will occur on the bar after the condition was found as true. Backtesting will calculate condition on the close of the bar.

      For information on the differences between historical and real-time executions please visit the following link: http://ninjatrader.com/support/helpG...ime_vs_bac.htm

      Please let me know if you have any questions.
      Thanks Patrick. From what I am reading in the guide it states:

      During backtest, strategies can ONLY be processed at the close of each bar.
      So I would assume that since Bar 1 closes, Bar 2 opens, the indicator finds the pattern, the strategy places the order then NT handles the fill of the order on the close of Bar 2 which would put it into Bar 3 correct?

      If that is the case would changing my strategy and indicator to use "OnBarClose" for backtesting purposes solve this problem and move the processing from the first tick of Bar 2, to the last tick of Bar 1? I would have to add extra logic for this but that's fine for backtesting purposes. Or would it work like this:

      Code:
      Assuming all are set to OnBarClose:
      
      Bar 1 - Pattern forms
      Bar 1 On Bar Close - Analyze pattern on index 0
      Bar 1 On Bar Close - Place Limit/Stop order
      Bar 2 - Order filled if price hit etc...
      This is just assuming that moving from calculating OnEachTick and doing bar close type operations in the IsFirstTickOfBar to OnBarClose solves the problem...

      Comment


        #4
        Please disregard, problem solved and understand how NT8 handles things in strategy analyzer. Thanks again for the help.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, 04-16-2024, 06:09 PM
        6 responses
        18 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by Jon17, Today, 04:33 PM
        0 responses
        1 view
        0 likes
        Last Post Jon17
        by Jon17
         
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        6 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        41 views
        0 likes
        Last Post alifarahani  
        Working...
        X