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

Historical vs Realtime Output

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

    Historical vs Realtime Output

    I am testing a Ninja strategy code to take some automated trades on ES on a 15-range chart. In my strategy, in OnBarUpdate(), I read/calculate these four values: current bar delta, previous bar delta, current bar delta percent and previous bar delta percent. Then, if (IsFirstTickeOfBar), based on the 4 above values and by comparing the price[0] and price [1], I make a trade decision to go long or short or nothing.

    When testing this code, both under sim and playback accounts, I noticed the following:

    Scenario 1: When this strategy is activated & set to calculate "on each tick": For the past/historical data, my code is returning the values correctly for current bar delta, previous bar delta, current bar delta percent and previous bar delta percent. However when running realtime, the same code is returning these four values for the previous respective bars instead (by shifting one bar to left, for example, takes the previous bar as the current bar etc).

    Scenario 2: When this strategy is activated & set to calculate "on bar close": For the past/historical data, my code is returning the values correctly for current bar delta, previous bar delta, current bar delta percent and previous bar delta percent. However when running realtime, the same code is returning current bar delta as 0, and current bar's delta as previous bar delta etc.

    In summary, I am getting the correct values returned when running this strategy on the historical data but not on realtime. Any idea what is causing this issue? Thanks!​

    #2
    Hello rsz16,

    Thanks for your post.

    What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.0.?.? or 8.1.?.?)

    Which instrument and interval are you using? (Ex: 1-Minute ES 06-23, 500-Tick NQ 06-23, etc.)

    Are you comparing backtest results in the Strategy Analyzer to the strategy running real time on a chart?

    Please provide me with a reduced exported copy of the strategy and the exact steps and settings used to reproduce this behavior so that I may look into this matter further.

    To export a strategy, go to Tools > Export > NinjaScript AddOn.

    Note that a reduced copy refers to a copy of the script that contains the minimum amount of code needed to reproduce the issue. All other code is commented out or removed.

    To create a copy of your script to modify, open a New > NinjaScript Editor, select your script, right-click in the Editor, select 'Save as', name the script, and click OK.​

    I look forward to assisting further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thank you Brandon!

      I'm currently using version 8.1.1.6 64-bit and the the interval/instrument is 15 Range ES 06-23. I also do use the strategy analyzer, but I'm comparing the output from market replay (for dates 6-8-23 and 6-9-23) to real time trading. As suggested, I can export and send you the code. Could you please let me know your Ninja email ID or email me a test message so I can email you the code? Thank you!​

      Comment


        #4
        Hello rsz16,

        Thanks for your note.

        I have received ad replied to your email.

        Please forward any questions you have in regard to this topic to that email.
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jxs_xrj, 01-12-2020, 09:49 AM
        5 responses
        3,290 views
        1 like
        Last Post jgualdronc  
        Started by Touch-Ups, Today, 10:36 AM
        0 responses
        6 views
        0 likes
        Last Post Touch-Ups  
        Started by geddyisodin, 04-25-2024, 05:20 AM
        8 responses
        61 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Option Whisperer, Today, 09:55 AM
        0 responses
        7 views
        0 likes
        Last Post Option Whisperer  
        Started by halgo_boulder, 04-20-2024, 08:44 AM
        2 responses
        24 views
        0 likes
        Last Post halgo_boulder  
        Working...
        X