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

TickReplayIndicator - Processing historical data

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

    TickReplayIndicator - Processing historical data

    TickReplayIndicatormyTickReplayIndicator=null;

    protectedoverridevoidOnStateChange()
    {
    if(State==State.SetDefaults)
    {
    Name="TestHost";
    }
    elseif(State==State.DataLoaded)
    {
    // Store a reference to the Tick Replay indicator before State.Historical
    // Doing so ensures the hosted indicator will run through Tick Replay
    myTickReplayIndicator=TickReplayIndicator();

    // For a strategy, you can just call AddChartIndicator(TickReplayIndicator());
    // However this also adds a copy of the indicator to the chart, which may or may not be desired
    // For calculation purposes only, storing the reference should all that needs to be required.
    }
    }

    protectedoverridevoidOnBarUpdate()
    {
    // Access the stored reference which calculates through
    // historical Tick Replay data and print the value as expected
    Print(myTickReplayIndicator[0]);
    }
    I refer to the above example code on the following NT8 help page; https://ninjatrader.com/support/help...don_window.htm

    1. If I understand this concept correctly, data processing in hisorical and realtime states can in some circumstances generates different outcomes because of the way the logic is processed, historic will always compute based on a full bar whereas realtime will compute based on the last bar as it is being processed. This makes sense if I understand it correctly?

    2. The referenced code provides a way for Ninjatrader to process historical data on a tick by tick basis, so that it is processed in the same way as realtime data?

    3. If the first 2 points are correct and I wish to implement this type of processing to historic data, how can I access the above code. When I try to implement it in an indicator, the type or namespace "TickReplayIndicator" could not be found. Is there a reference I need to specifically add to get his function to work?

    Thanks

    #2
    Hello b16_aln,

    Thanks for the post.

    It looks like the link you provided was for some addon concepts, to match the code you provided here is the link to the sample:
    https://ninjatrader.com/support/help...eplayIndicator

    1). Historical and realtime would process in a similar way however in realtime you would have the full granularity because of the incoming tick data. In historical data you would process using the OHLC of the bar and always using OnBarClose. When using OnBarClose processing you would always be referencing the last Closed bar's data when using [0] bars ago. In realtime if you are using OnBarClose the [0] BarsAgo represents the same thing or last close bar, the building bar is not considered. If you use OnEachTick or OnPriceChange in realtime the [0] would represent the last change or tick rather than the last bars close because the building bar is now used.When enabling TickReplay you will see OnBarUpdate is called historically for each tick as well. You can see a good image of that process in the following page: https://ninjatrader.com/support/help...sub=tickreplay

    2). The referenced code is not specifically how to process data on a tick by tick bases, this sample shows what is needed to make sure any hosted indicator processes historical data at all when being hosted. This is the "Calling a Tick Replay indicator from another Indicator or Strategy" sample. If you don't use the code like that with any indicator you call its historical state will not be called creating differences in how the results would be. If you call any indicator from a strategy you should in most cases call one of its plots from OnBarUpdate or call its Update() method so that it processes historically. This is shown for tick replay because it is an important part of the tick replay processing of historical tick data.

    3) TickReplayIndicator is a placeholder, you would insert whatever indicator name you are using in place of that. If you used the SMA you would use SMA in place of TickReplayIndicator.

    Generally a tick replay indicator will make use of the tick replay logic, for example the SMA does not use OnMarketData so it would not make use of that part of tick replay. If you developed an indicator that makes use of any part of the tick replay features you need to make sure to call the indicator like the sample shows using the custom indicators name in place of TickReplayIndicator.

    I look forward to being of further assistance.



    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks Jesse,

      Is there any way to alter the historic bar processing logic to enable the platform to build all hisotric bars on a tick by tick basis then rather than having to use tick replay so it mimics realtime?

      Comment


        #4
        Hello b16_aln,

        TickReplay would be that mechanism, if you are not using tick replay you would be using the bars historical data which is just the OHLC for each bar. TIckReplay lets the bars build tick by tick and also allows a script to use the data/events.

        The only other alternative would be to load no historical data at all in a chart and then play forward in time through playback data. That would limit the script to only executing in realtime.

        I look forward to being of further assistance.

        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks Jesse. If I understand what your saying correctly, by selecting ShowTickReplay in Tools>Options>Market data then historic data should be processed on a tick by tick bases and therefore results should mimic using the Playback Connection?

          If this is the case then it does not appear to be exucuting as expected in my case.

          Comment


            #6
            Hello b16_aln,

            The option you mentioned is just to show the TickReplay checkbox, that does not turn TickReplay on. When you configure a chart the DataSeries window will have a TickReplay checkbox after enabling the option menu item. You would need to check that and then create the chart, it would then load. It should take longer to load at that point.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Excellent, got it. Thank you Jesse.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Brevo, Today, 01:45 AM
              0 responses
              2 views
              0 likes
              Last Post Brevo
              by Brevo
               
              Started by aussugardefender, Today, 01:07 AM
              0 responses
              3 views
              0 likes
              Last Post aussugardefender  
              Started by pvincent, 06-23-2022, 12:53 PM
              14 responses
              238 views
              0 likes
              Last Post Nyman
              by Nyman
               
              Started by TraderG23, 12-08-2023, 07:56 AM
              9 responses
              384 views
              1 like
              Last Post Gavini
              by Gavini
               
              Started by oviejo, Today, 12:28 AM
              0 responses
              4 views
              0 likes
              Last Post oviejo
              by oviejo
               
              Working...
              X