Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Add Indicator with custom color

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

    Add Indicator with custom color

    Hi!!

    I am adding a SMA line in my code, inside Initialize(), like this:
    Code:
    Add(SMA(5));
    The default color will be orange.

    I tried this:

    Code:
    SMA s = SMA(5);
    s.BackColor = Color.Blue;
    Add(s);
    So, lines are added, but colors are still orange. It is obviously the wrong one.

    Which property is the correct one to set?

    #2
    Hello vhanded,

    Thank you for your post.

    The code would use PlotColors: http://www.ninjatrader.com/support/h...plotcolors.htm
    Code:
    			s = SMA(20);
    			Add(s);
    			s.PlotColors[0][0] = Color.Blue;

    Comment


      #3
      Sorry for late reply. I just tested it, and I got this error:

      **NT** Failed to call method 'Initialize' for strategy
      Code:
      'CrossTimeSeries/7c4a8ea75de943b2944a1dbc7630991f': Object reference not set to an instance of an object.
      This is my code in Initialize:
      Code:
      SMA fastLine = SMA(5);
      Add(fastLine);
      fastLine.PlotColors[0][0] = Color.AliceBlue;
      If I remove the 3rd line, everything is fine, but I will just get the default Color.

      Comment


        #4
        I'm not a strategy programmer, but the logic tells that we should move this line to OnBarUpdate():

        fastLine.PlotColors[0][0] = Color.AliceBlue;
        Give it a try!
        ninZa
        NinjaTrader Ecosystem Vendor - ninZa.co

        Comment


          #5
          Hi Ninja,

          I tested it too, no error, but the line color is still default color.

          Comment


            #6
            Have you tried this in Initialize():

            fastLine.Plots[0].Pen.Color = Color.AliceBlue;
            ninZa
            NinjaTrader Ecosystem Vendor - ninZa.co

            Comment


              #7
              YUP! This is the solution! Thanks!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by arvidvanstaey, Today, 02:19 PM
              0 responses
              2 views
              0 likes
              Last Post arvidvanstaey  
              Started by mmckinnm, Today, 01:34 PM
              3 responses
              5 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by f.saeidi, Today, 01:32 PM
              2 responses
              5 views
              0 likes
              Last Post f.saeidi  
              Started by alifarahani, 04-19-2024, 09:40 AM
              9 responses
              55 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by Conceptzx, 10-11-2022, 06:38 AM
              3 responses
              60 views
              0 likes
              Last Post NinjaTrader_SeanH  
              Working...
              X