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 GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,221 views
              0 likes
              Last Post xiinteractive  
              Started by andrewtrades, Today, 04:57 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by chbruno, Today, 04:10 PM
              0 responses
              7 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              437 views
              0 likes
              Last Post Delerium  
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              9 views
              0 likes
              Last Post FAQtrader  
              Working...
              X