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

How to test Calculate .OnBarClose vs .OnEachTick

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

    How to test Calculate .OnBarClose vs .OnEachTick

    NT Forum,

    I understand a multi-time frame Strategy must calculate .OnEachTick, to access the currently developing bar in each time frame (How Bars Data is Referenced), and confirmed in How to structure Multi-Time Frame Strategy.

    I am attempting to convert Indicators built for Calculate.OnBarClose to correctly calculate .OnEachTick and .OnBarClose; evaluating at the correct time and referencing the correct bar data. Example indicator attached.

    I was of the understanding Playback Connection would allow me to test Indicators as if under live conditions, and thus test Calculate .OnBarClose vs .OnEachTick. However, this does not appear to be the case. As expected, on a historical chart State is .Historical until the final BarUpdate where it becomes .Realtime. With Playback Connection (using Market Replay or Historical), State again remains .Historical until the final BarUpdate.

    While I have seen NT8 - Developing for Tick Replay, I am unsure it if it is the solution and how to implement.

    Please advise how to test Indicators under .OnBarClose and .OnEachTick.

    As always, thanks
    Shannon
    Attached Files

    #2
    Hello Shansen,

    Thank you for your note.

    In market replay state will be in state.historical until the last historical bar, once the replay data begins to play/build bars, state will be in state.realtime. I put together a video demonstrating this.

    I placed the print state statement in On Bar Update.
    Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


    Please let us know if you are still unclear or need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      AlanP,

      Thank you for your response.

      It appears my issue extends from attempting to create a custom instrument, importing tick data, and then running market replay on the custom instrument. I may have mis-interpretted NinjaTrader_Brett's post in the thread FEATURE REQUEST - Automated unit testing.

      I believe I have successfully exported tick (or more specifically 10 tick) data for the instrument "CL 12-17". The tick data was then imported to a custom instrument "TEST_CL". However, it appears the imported tick data does not generate Market Replay data. In the Historical Data window under Historical, tick data is present for "TEST_CL", however under Market Replay no data is present for "TEST_CL". Short explanatory video at https://www.screencast.com/t/KKOyJXGDV

      Please advise where I have gone wrong in creating a custom instrument with Market Replay (so that I may test .OnBarClose vs .OnEachTick).

      Comment


        #4
        Hello Shansen,

        Market Replay Data and Tick Data are different, for example Replay data is going to contain order book information.

        When you are running replay, is the playback controller set to Market Replay or Historical? (see screen shot).

        I look forward to your reply.
        Attached Files
        Alan P.NinjaTrader Customer Service

        Comment


          #5
          The playback controller set to Market Replay.

          Comment


            #6
            Hello Shansen,

            If you set it to historical and run the player, do your charts update for your custom instrument?

            I look forward to your reply.
            Alan P.NinjaTrader Customer Service

            Comment


              #7
              I believe you've cracked it! With the custom instrument "TEST_CL", the chart does not update in any way under Market Replay Playback. The chart does update under Historical Playback, complete with the transition from Historical to Realtime. Thank you!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by jclose, Today, 09:37 PM
              0 responses
              4 views
              0 likes
              Last Post jclose
              by jclose
               
              Started by WeyldFalcon, 08-07-2020, 06:13 AM
              10 responses
              1,413 views
              0 likes
              Last Post Traderontheroad  
              Started by firefoxforum12, Today, 08:53 PM
              0 responses
              10 views
              0 likes
              Last Post firefoxforum12  
              Started by stafe, Today, 08:34 PM
              0 responses
              10 views
              0 likes
              Last Post stafe
              by stafe
               
              Started by sastrades, 01-31-2024, 10:19 PM
              11 responses
              169 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Working...
              X