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

Minute Time Frame Indicators in a TickTime Frame strategy

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

    Minute Time Frame Indicators in a TickTime Frame strategy

    I would like to use a 1-minute indicator (for stop/limit values) in a tick timeframe strategy, both on the same instrument. The indicator values should only be updated once every minute.
    e.g. FDAX, tick timeframe and a SMA(10) on a 1 minute period FDAX => SMA Value is updated only once a minute.

    When I add a 2nd bar object to the strategy:
    Code:
    Add(PeriodType.Minute, 1);
    Add(SMA(10));
    This object will updated on every tick, even if I limit the OnBarUpdate() to the underling instrument on the ticktimeframe with
    Code:
    if (BarsInProgress != 0)
     return;
    It is the same with the example strategy:
    When I add the SampleMultiTimeFrame strategy that is provided with NT 6.0.0.10 to a ticktimeframe chart two SMAs are plotted which are updated several times in a single minute. In the strategy code they a defined as a 5 minute SMA and a 50 minute SMA.

    Did I misunderstood something? Why is the SMA updated on every tick?

    #2
    imported post

    Indicators in a strategy are updated according the CalculateOnBarClose property of the strategy holding the indicators.

    a) if the strategy has CalculateOnBarClose=True, then the indicators will run with CalculateOnBarClose=True
    a) if the strategy has CalculateOnBarClose=False, then the indicators will run with CalculateOnBarClose=False

    Comment


      #3
      imported post

      I tried both CalculateOnBarClose=true and CalculateOnBarClose=false on the SampleMultiTimeFrame strategy. It looks like there is no difference, the plots are the same.

      The minute based SMA is updated on every bar close (= every tick) of the tick timeframe underlying and not on every bar close (which is every 10 minutes) of it´s own timeframe.

      How can I create an indicator that is updated only on a certain time intervall?



      Comment


        #4
        imported post

        Hmm, let's make sure we are on the same page: As you throw a strategy/indicator on a chart, it's executed once per bar for the historical part of the bars series. no matter what the CalculateOnBarClose property is set to. CalculateOnBarClose=False only is relevent for strategies/indicators running on incoming realtime data.

        Reason: On historical bars data there are no ticks. One bar only triggers OnBarUpdate once.

        Comment


          #5
          imported post

          Sorry, maybe I did not point it out clearly.

          I use a tick time chart and I have historical tick data, so every tick is a bar.

          When I throw the strategy/indicator on this chart it is executed once per bar = once per tick. It obviosly does not matter if CalculateOnBarClose is set to true or false.

          How can I add an indicator that is updated only once per minute, to a ticktime chart or a strategy running on a tick time chart?

          Comment


            #6
            imported post

            I see. Sorry you can not visualize on chart an indicator running on a different timeframe than the chart.

            But you can add an indicator running on a minute time frame to a strategy running on a tick timeframe. If the strategy then runs on CalculateOnBarClose=false, the indicator will only calculate once per per minute.

            The docs (NinjaScript->Developing Custom Strategies->Multi Time Frame & Instrument) hold a sample on how to run indicators on different timeframe than the strategy.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by stafe, 04-15-2024, 08:34 PM
            6 responses
            30 views
            0 likes
            Last Post stafe
            by stafe
             
            Started by adeelshahzad, Today, 03:54 AM
            4 responses
            25 views
            0 likes
            Last Post adeelshahzad  
            Started by merzo, 06-25-2023, 02:19 AM
            10 responses
            823 views
            1 like
            Last Post NinjaTrader_ChristopherJ  
            Started by frankthearm, Today, 09:08 AM
            5 responses
            17 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            43 views
            0 likes
            Last Post jeronymite  
            Working...
            X