Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

multi timframe - gaps in plots.....

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

    multi timframe - gaps in plots.....

    Hi,
    I have a strang problem with plotting. I created an indicator, wich 'digitaly' plots values (a MACD with standard Deviation). When the MacdLine is over the StdDev of Macdline, there should be a green plot. Under the -StdDev it should be red and between, it shoukld be gray. So far - so good.

    This Indicator runs in a 1 min Chart an calculates the values of this indicator in a 3min chart. This works fine. But if I add a second series (5min), the plot of the 5min will be fine and the plot of the 3 min has random gaps..... (see picture)

    Here is my code:
    Code:
     
    protected override void Initialize()
    {
    MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
    
    Add(PeriodType.Minute, 3); // BarsArray[1] = 3min
    Add(PeriodType.Minute, 5); // BarsArray[2] = 5min
    
    Add(new Plot(Color.FromKnownColor(KnownColor.Lime), PlotStyle.Dot, "Up3min"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Dot, "Down3min"));
    Add(new Plot(Color.FromKnownColor(KnownColor.ControlDark), PlotStyle.Dot, "Neutral3Min"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Lime), PlotStyle.Dot, "Up5min"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Red), PlotStyle.Dot, "Down5min"));
    Add(new Plot(Color.FromKnownColor(KnownColor.ControlDark), PlotStyle.Dot, "Neutral5Min"));
    Overlay = false;
    }
    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    if(CurrentBars[2] < 19) return;
    
    if(MacdBBSimple(BarsArray[1], Length, Length, 1,Length * 2).MacdLine[0] > MacdBBSimple(BarsArray[1], Length,Length, 1,Length * 2).UpperBand[0])
    Up3min.Set(-3);
    else if(MacdBBSimple(BarsArray[1],Length, Length, 1,Length * 2).MacdLine[0] < MacdBBSimple(BarsArray[1],Length, Length, 1,Length * 2).LowerBand[0])
    Down3min.Set(-3);
    else
    Neutral3Min.Set(-3);
    
    
    if(MacdBBSimple(BarsArray[2], Length, Length, 1,Length * 2).MacdLine[0] > MacdBBSimple(BarsArray[2], Length,Length, 1,Length * 2).UpperBand[0])
    Up3min.Set(-5);
    else if(MacdBBSimple(BarsArray[2],Length, Length, 1,Length * 2).MacdLine[0] < MacdBBSimple(BarsArray[2],Length, Length, 1,Length * 2).LowerBand[0])
    Down3min.Set(-5);
    else
    Neutral3Min.Set(-5); 
    
    }
    I tried several things to fix this, without sucsess. I loaded more data, I use the MaximumBarsLookBack.Infinite, I tried to fix it with Bars in Progress.... But nothing helps. The confusing thing is: Yesterday I wrote an indicator, wich digitaly plots the DM for 1min,3min,5min,15min, 8range, 4901tick and 30min in a 1 min-Chart. This works without any problem!

    Jens
    Attached Files

    #2
    Hi Jens,

    For multicolored plots in version 7, best is to follow the new approach, where you assign conditionally a PlotColors value. The approach you're using was effective in NT6.5, but now you can trim a lot of resources and avoid Reset() calls when using PlotColors.

    See the NT7 file in this reference sample for a guide to this approach:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hello RyanM,

      it works. Could you please explain, why the old version doesn't work fine?

      Jens

      Comment


        #4
        The approach you're using is good for NT6.5, but since adding PlotColors in NT7, this is the only supported technique for multicolor plots.

        You should be able to get the multiplot approach working by calling .Reset() on the plots when they're not true, but this requires extra coding and consumes more resources than using PlotColors.

        if(Up3MinConditions)
        {
        Up3min.Set(-3);
        Down3min.Reset();
        Neutral3Min.Reset();
        }
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

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