Announcement

Collapse
No announcement yet.

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]);

    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.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        134 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        75 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        119 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        114 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        90 views
        0 likes
        Last Post CarlTrading  
        Working...
        X