Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Applying Different Time Frame Moving Average

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

    Applying Different Time Frame Moving Average

    Hello,

    I would like to add a moving average to my 5-minute chart but base the calculation on a 15-minute time frame. I've been looking through the indicator settings but can't seem to find the option to adjust the time frame for the moving average independently of the chart's time frame.

    Could you guide me on how to apply a 15-minute moving average to a 5-minute chart? Your help would be greatly appreciated!

    Thank you!​

    #2
    Hello Hezi100,

    Thanks for your post.

    You could call the AddDataSeries() method in the script to add a 15-minute secondary data series to use for calculations.

    Then, you would pass in the BarsArray of the added series into the indicator when instantiating the indicator in State.DataLoaded.

    BarsArray[0] would be the BarsArray of the primary series. BarsArray[1] would be the BarsArray of the first added series, and so on.

    For example:

    //class-level variable
    private SMA mySMA;

    //State.Configure
    else if (State == State.Configure)
    {
    AddDataSeries(BarsPeriodType.Minute, 15);
    }

    //State.DataLoaded
    else if (State == State.DataLoaded)
    {
    mySMA = SMA(BarsArray[1], 14);
    }


    The SMA (mySMA) would then calculate from the added 15-minute series.

    You could then call AddPlot() in the script and assign mySMA[0] to the plot to plot the value on the chart.

    See the help guide documentation below for more information.

    AddDataSeries(): https://ninjatrader.com/support/help...dataseries.htm
    BarsArray: https://ninjatrader.com/support/help.../barsarray.htm
    Working with Multi-TimeFrame/Multi-Instrument NinjaScripts: https://ninjatrader.com/support/help...nstruments.htm
    AddPlot(): https://ninjatrader.com/support/help...t8/addplot.htm
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment

    Latest Posts

    Collapse

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