Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Beta 21 Multi Time Frame Bug?

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

    Beta 21 Multi Time Frame Bug?

    Hi

    There seems to be a bug with multi time frame strategies in beta 21.

    On a 6 range chart, I want to access EMAs on an 18 range data series and then just change the back colour when the 6 range bar spans the EMA on the 18 range dataseries.

    This is the code:

    PHP Code:
            protected override void Initialize()
            {
                CalculateOnBarClose = false;
                Enabled                = true;
                Add(PeriodType.Range, 18);
            }
    
            protected override void OnBarUpdate()
            {
                BackColor = Color.Transparent;
                int mtf                = 1;
                int    mtfAverage        = 20;
    
                double mtfEMA = EMA(BarsArray[mtf], mtfAverage )[0];    
                DrawDot("Ema" + CurrentBar.ToString(), true, 0, mtfEMA, Color.DarkMagenta);
    
                if ( High[0] > mtfEMA
                    && Low[0] < mtfEMA
                    && Close[0] == High[0] )
                {
                    BackColor = Color.Bisque;
                }
    
            } 
    
    Very simple code, but I get some bars that are nowhere near the 18 range EMA(20) painted. See the image, for an example.

    That is all the strategy does at the moment - there is no other code to cause the bars to be highlighted incorrectly.

    Thanks
    Chris
    Attached Files

    #2
    Hello,

    Thank you for your forum post.

    If you right click on this and select reload NinjaScript does the results change? As I believe this would be expected if you are running live mode with range bars.

    I look forward to assisting you further.
    BrettNinjaTrader Product Management

    Comment


      #3
      If you right click on this and select reload NinjaScript does the results change?
      No the wrong bars are still identified when reloading the Ninjascript.

      As I believe this would be expected if you are running live mode with range bars.
      What do you mean by this please?

      Chris

      Comment


        #4
        Operandi,

        What I recommend is that you really filter your code to various BarsInProgress contexts. Right now you have the same code block being executed on both BIPs. Keeping different BIPs separate will ensure a clearer picture. From there you can then also print the CurrentBar of BIP 0 and know exactly which bar your condition is true on and understand why it is painting on the bar it is painting on.

        I suggest you blanket everything with if (BarsInProgress == 0) otherwise even in BIP1 you will be doing calls like BackColor = Color.Transparent which would most likely not be desired.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Many thanks, Josh

          It seems to work fine now that I have rewritten the code as you suggest, so this is not a bug after all!

          Chris

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          596 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          343 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          556 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          554 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X