Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Plot SMA's

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

    Plot SMA's

    Hi Support,

    I'm trying to work out how to plot a SMA with a period of 12 on a chart.

    I used the wizard for this.

    Code is as such....

    #region Variables
    // Wizard generated variables
    privateint period12 = 12; // Default setting for Period12
    #endregion

    protectedoverridevoid Initialize()
    {



    Add(
    new Plot(Color.FromKnownColor(KnownColor.CornflowerBlu e), PlotStyle.Line,"Plot12"));

    Overlay = true;

    CalculateOnBarClose=
    false;

    .....//This section I can't work out?

    protectedoverridevoid OnBarUpdate()
    {
    Plot12.Set(SMA(period12); ??
    }

    How do I set Plot 12 to the SMA period12? So that it will plot the SMA of period value 12.


    Thanks
    Bruce



    #2
    Bruce, for the SMA you could also use the per default supplied SMA indicator from NT.

    But for your code you would need to pick a double value from the series you access here (the SMA method returns a series per default)

    So for example :

    Plot12.Set(SMA(period12)[0]);
    BertrandNinjaTrader Customer Service

    Comment


      #3
      OK Thanks for your help...Got that working.

      Don't quite understand the [0] though... Is this for the current Bar?

      Comment


        #4
        Great to hear, correct index [0] is the most recent completed bar.
        BertrandNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by trilliantrader, 04-18-2024, 08:16 AM
        4 responses
        18 views
        0 likes
        Last Post trilliantrader  
        Started by mgco4you, Today, 09:46 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by wzgy0920, Today, 09:53 PM
        0 responses
        9 views
        0 likes
        Last Post wzgy0920  
        Started by Rapine Heihei, Today, 08:19 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Rapine Heihei, Today, 08:25 PM
        0 responses
        10 views
        0 likes
        Last Post Rapine Heihei  
        Working...
        X