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

Multiple time frames - Double count

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

    Multiple time frames - Double count

    Hi,

    I am developing a multiple time frame indicator which uses a 5 minutes and 30 minutes time frame. The script is applied to a 5 minute chart, and I use Add(PeriodType.Minute,30); for the 30 minutes time frame.

    I noticed while troubleshooting that every 30 minutes the OnBarUpdate() section is being parsed twice: once for the 5 minute bar that just completed, and then another time for the 30 minutes bar that just completed. Add another time frame using Add(PeriodType.Minute,60); and the parsing is done three times every hour.

    While printing the values of Stochastics %K on the debuging window I noticed that the first parse gives a correct %K value for the 5 minute time frame. On 2nd parse, an invalid %K that comes from I don't know where is calculated again. This generates bad signal (arrows up or down) on my chart.

    The question: Is there a way to specify, in the OnBarUpdate() section that I want the script to exit ( return ) whenever the OnBarUpdate is applied to the 30 minute bar?

    Thanks in advance.

    -mp

    #2
    mp, yes you can control this with the BarsInProgress property in NinjaScript -



    So for your case: if (BarsInProgress == 1) return; // 1 being the first added series, so your 30 min.

    So updates to the primary 5 min and tertiary 60 min would still come through then.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Yes! That fixed it. Many thanks!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      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
      15 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  
      Started by yertle, Today, 08:38 AM
      5 responses
      16 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by adeelshahzad, Today, 03:54 AM
      3 responses
      19 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Working...
      X