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

Indicator synced to slower TF to update on faster TF as slower TF bar is building

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

    Indicator synced to slower TF to update on faster TF as slower TF bar is building

    Hi. Sorry for the confusing title... I thought I found what I needed here but not exactly.

    Primary timeframe slower (15-minute). Secondary timeframe faster (1-second). Trades taken on the secondary timeframe based on reading of indicator that is synced to the primary series. Let's say SMA. Problem is SMA[0] points to the prior primary bar because the currently building primary bar did not close yet. I want the indicator reading to be up-to-date as the bar is building. I set the strategy and indicator both to Calculate.OnEachTick, didn't help. Might be because I'm currently backtesting, no realtime. Then how to do it? It seemed fairly simple a task and I hit a wall.

    #2
    Hello digibob,

    Thanks for your post.

    Backtesting would be the issue because of the data that is being used only contains the OHLC of the finished bars and not the ticks that made up the bar. If you have the tick data available for the duration of the backtest period, you can enable "Tick Replay" which may provide what you need. Note that this will slow down the strategy analyzer.

    A better solution would be to use Playback with market replay data as this will provide a closer simulation to real-time data. It is a slower process than the strategy analyzer but would provide more accurate info. Here is a link to Playback in the help guide: https://ninjatrader.com/support/help...connection.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi Paul. Thanks for your answer.

      I worked with Playback before. Unfortunately testing months/years back is not practical this way.

      I tried Tick Replay as per your suggestion (I have tick data) and there is no difference. The indicator value remains fixed throughout the building of a new bar. It continues to show the value from the prior bar (the last completed one).

      (To enable Tick Replay, is there something more to do besides clicking the checkbox in the analyzer?)

      Actually I was hoping for a code solution. The issue is not about tick specifically. It could have been 15-minute and 5-minute, or monthly and daily. The strategy anyway uses a faster timeframe so higher granularity is there, just how can it be utilized to produce an up-to-date reading on the indicator that is synced to the slower timeframe?

      Maybe sync an indicator to the faster timeframe to mimic the one synced to the slower timeframe? I did try that briefly, the indicator reading was inaccurate.

      So is there nothing that can be done in code to workaround this?

      Comment


        #4
        Hello digibob,

        Thanks for your reply.

        Click tick replay would be all that is needed as the checkbox does not appear unless you have already enabled it Tools>Options>Marketdata.

        Did you print out the values of the indicator(s) when using tick replay and with your strategy set to calculate.OnEachtTick to know that they are not updating? If not please test a short test period and advise your observations.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hi Paul. Thanks for your help. The indicator was calling another indicator and that other indicator was set to Calculate.OnBarClose. I changed it to OnEachTick and it's working now.

          This solution is for backtesting. What about when running the strategy in a chart outside the analyzer? There is no Tick Replay. Realtime will work but historical calculations (trades, drawings) will not match realtime calculations. It may also be a problem when transitioning from historical to realtime.

          Comment


            #6
            Hello digibob,

            Thanks for your reply.

            Good debugging on your part.

            You can run tick replay on a chart which will help for the historical portion.

            Alternately, you could prevent historical trading and only trade when live, the benefit here would be to not be dependant on the resource-consuming tick replay just for historical orders. When live with Calculate.OnEachTick (or Calculate.OnPriceChange) all of the references will be pointing to the current forming bars in each series.




            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Oh, Tick Replay is a property of data series. I thought it was not available on a chart because I looked for it in strategy properties.

              I appreciate your help, Paul. Many thanks.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by LiamTwine, Today, 08:10 AM
              0 responses
              1 view
              0 likes
              Last Post LiamTwine  
              Started by Balage0922, Today, 07:38 AM
              0 responses
              5 views
              0 likes
              Last Post Balage0922  
              Started by JoMoon2024, Today, 06:56 AM
              0 responses
              6 views
              0 likes
              Last Post JoMoon2024  
              Started by Haiasi, 04-25-2024, 06:53 PM
              2 responses
              19 views
              0 likes
              Last Post Massinisa  
              Started by Creamers, Today, 05:32 AM
              0 responses
              6 views
              0 likes
              Last Post Creamers  
              Working...
              X