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

Change the colour of a plot of a named indic

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

    Change the colour of a plot of a named indic

    NT Forum,

    Leveraging off the example provided by koganam (http://ninjatrader.com/support/forum...7907#poststop)), in the below code what changes must be made to
    1) plot the added _sma object, and
    2) set the _sma plot color (e.g. Color.Green)

    Code:
    public class exampleIndicator : Indicator
    {
      private SMA _sma;
      private int _period = 12;
    
      protected override void Initialize()
      {
        //  ??  Add(new Plot(Color.Green, "SMA"));
      }
    
      protected override void OnStartUp()
      {
        _sma = SMA(_period);
      }
      
      protected override void OnBarUpdate()
      {
        // code referencing _sma
      }
    }
    Thanks
    Shannon

    #2
    Hello Shansen,

    Thanks for your post.

    Here is an example using your code:

    Code:
    private SMA _sma;
    private int _period = 12;
    
    protected override void OnStartUp()
    {
      _sma = SMA(_period);
    }		
    		
    protected override void OnBarUpdate()
    {
    Value.Set(_sma[0]);    // set for output
    PlotColors[0][0] = Color.Red;  // set Plot color
    }

    Paul H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Matt Skinner, Yesterday, 12:23 AM
    3 responses
    28 views
    0 likes
    Last Post Matt Skinner  
    Started by Dan_TUK, Today, 05:14 AM
    0 responses
    5 views
    0 likes
    Last Post Dan_TUK
    by Dan_TUK
     
    Started by WHICKED, 06-27-2023, 12:07 PM
    65 responses
    766 views
    1 like
    Last Post llanqui
    by llanqui
     
    Started by wzgy0920, 04-20-2024, 06:09 PM
    7 responses
    59 views
    0 likes
    Last Post Joia_
    by Joia_
     
    Started by sofortune, Today, 02:31 AM
    0 responses
    7 views
    0 likes
    Last Post sofortune  
    Working...
    X