Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plotting 30 day SMA on minute timeframe strategy

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

    Plotting 30 day SMA on minute timeframe strategy

    Hi,

    I want to develop a strategy in visual studio on minute timeframe, but I want to plot 30 day SMA on my strategy. I am thinking about modifying the SMA indicator code in Ninja Trader but I am not sure how to modify it to make it always calculate on a daily basis. Can you please help me on this?

    Thank you.
    Last edited by wyifei6688; 06-30-2023, 10:32 PM.

    #2
    Hello wyifei6688,

    Thanks for your post.

    The SMA indicator could be plotted in a NinjaScript strategy by using the AddChartIndicator() method.

    We have a help guide page linked here that talks about adding indicators to a strategy: https://ninjatrader.com/support/help..._strategie.htm

    See this help guide page for more information about the AddChartIndicator() method:

    You could also consider adding a secondary 1-minute data series to the strategy by using AddDataSeries() and instantiate the SMA indicator to calculate using that added series by passing in the BarsArray index you would like to use for calculations.

    For example, if the 1-minute data series is the first added series in the script, you could pass BarsArray[1] into SMA(), such as SMA(BarsArray[1], 30).

    This could be set up in the Strategy Builder by adding a 1-Minute data series to the strategy on the Additional Data screen and creating a condition using the SMA indicator and setting the input series to use the added 1-minute series. Then, you could click the 'View code' button to see the generated syntax.

    See the help guide documentation below for more information and sample code.

    Working with Multi-Timeframe/Multi-Instrument NinjaScripts: https://ninjatrader.com/support/help...nstruments.htm
    AddDataSeries: https://ninjatrader.com/support/help...dataseries.htm
    BarsArray: https://ninjatrader.com/support/help.../barsarray.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 NullPointStrategies, Today, 05:17 AM
    0 responses
    52 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    130 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    70 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    44 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    48 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X