Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

MultiTimeFrameSMA

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

    MultiTimeFrameSMA

    The SMA of the 15 min timeframe in a 5 min chart doesn't look correct.

    Are there any problems in my code?

    protected override void Initialize()
    {

    Add(PeriodType.Minute, 15);
    Add(PeriodType.Minute, 30);
    Add(PeriodType.Minute, 60);
    Add(new Plot(Color.FromKnownColor(color), PlotStyle.Line, "SMA5"));
    Add(new Plot(Color.FromKnownColor(color), PlotStyle.Line, "SMA15"));
    Add(new Plot(Color.FromKnownColor(color), PlotStyle.Line, "SMA30"));
    Add(new Plot(Color.FromKnownColor(color), PlotStyle.Line, "SMA60"));


    CalculateOnBarClose = true;
    Overlay = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {
    // Use this method for calculating your indicator values. Assign a value to each
    // plot below by replacing 'Close[0]' with your own formula.
    SMA5.Set(SMA(period)[0]);
    SMA15.Set(SMA(BarsArray[1], period)[0]);
    SMA30.Set(SMA(BarsArray[2], period)[0]);
    SMA60.Set(SMA(BarsArray[3], period)[0]);
    }





    #2
    ... found it out in the meantime

    the problem was not the SMA of the 15 min, the problem was the 5 min itself

    After changing the code to

    SMA5.Set(SMA(BarsArray[0],period)[0]);

    now it works

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    164 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    319 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    246 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    350 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    179 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X