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 kinfxhk, 07-13-2026, 10:18 AM
    0 responses
    36 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 09:50 AM
    0 responses
    30 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 07:21 AM
    0 responses
    37 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-11-2026, 02:11 AM
    0 responses
    33 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by SalmaTrader, 07-07-2026, 10:26 PM
    0 responses
    144 views
    0 likes
    Last Post SalmaTrader  
    Working...
    X