Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi time-frame indicator

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

    Multi time-frame indicator

    Hey guys, I've written a SMA indicator that uses BarsArray and use inputs to plot SMA.

    The inputs are setup as properties for the indicator, so you can enter 5 times, these time entry's are the setting used in the period.

    protected override void Initialize()
    {
    Add(PeriodType.Minute, time1);
    Add(PeriodType.Minute, time2);
    Add(PeriodType.Minute, time3);
    Add(PeriodType.Minute, time4);
    Add(PeriodType.Minute, time5);
    Add(new Plot(Color.FromKnownColor(KnownColor.Blue), PlotStyle.Line, "LT1"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Aqua), PlotStyle.Line, "LT2"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Purple), PlotStyle.Line, "LT3"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Lime), PlotStyle.Line, "LT4"));
    Add(new Plot(Color.FromKnownColor(KnownColor.Gold), PlotStyle.Line, "LT5"));
    }

    I can get the SMA through a function for each indicator and even plot it, but the plots that are greater then the chart period don't join together.

    So for example, I set a chart with 10 minute bars, and set Time1 to 5, Time2 to 10, Time3 to 30, Time4 to 60 and Time5 to 300.

    The time period set greater then 10 don't join, like on the 30 minute mark it will draw a value but it is a little dot, any value in between the BarArray, for example 35, 40,50 etc
    the value of that plot is 0.

    How do I get it to keep the original value and plot on update? Or what am I doing wrong to make this not work? If i haven't explained this well enough Ill provide examples. Any help or examples at all would be greatly appreciated.

    #2
    Hello HappPappy,

    Thank you for your note.

    What is occuring here is the syncing of the data and what is calling OnBarUpdate.

    Since, the primary is shorter than the larger time frames, it will call OnBarUpdate more frequently and will update all the values that you are using to store the values for the higher time frames. Since, there is no update for the higher time frames the value will get updated with 0.

    To avoid this you can test for the value and then set it to the previous correct value for the higher timeframes.

    Additionally, you can try following the example below on syncing your indicators on different data series for the SMA -
    http://www.ninjatrader.com/support/f...ead.php?t=3572
    Cal H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    574 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    332 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
    553 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    551 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X