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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        580 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        336 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        102 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        552 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X