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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        164 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        318 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        246 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        350 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        179 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X