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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    81 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    68 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    55 views
    0 likes
    Last Post CarlTrading  
    Working...
    X