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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    63 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    90 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    47 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    105 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    63 views
    0 likes
    Last Post PaulMohn  
    Working...
    X