Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Change Color properties

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

    Change Color properties

    Depending on code I would like to allocate certain colors to a drawing symbol (e.g. Triangle)

    I have read several threads but they seem to pertain to Input or Serialization and I am not sure if I need this in order to make the change.

    I have tried creating something like:

    public color myColor=Color.SandyBrown; // In initialize

    public Color MyColor
    {
    get { return myColor; }
    set { myColor = value; }
    } // In properties

    and code like

    MyColor in place of say Color.Blue

    Thanks, Alan

    #2
    Hi Alan,

    You need to serialize colors when they are used as public inputs. A user could select a color from the indicator parameters. In order for these color selections to be preserved in workspaces or templates, they must be serialized.

    If you are conditionally assigning color values through code, then you don't need to structure as an input or serialize.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan yes I want assign via code, so is my example on the right track?

      regards

      Comment


        #4
        No, that example looks like an input.

        You can do this with or without variable declaration. If you want to use a color variable, you need only one declaration per color in the variables region and nothing in the properties region.

        private color myColor1 = Color.Green;
        private color myColor2 = Color.Red;

        if (Close[0] > Open[0])
        DrawTriangleDown("Tag" + CurrentBar, true, 0, High[0], Color.Green);

        else if (Close[0] < Close[1])
        DrawTriangleDown("Tag" + CurrentBar, true, 0, High[0], Color.Red);

        If you want to use a color variable you would place that instead of Color.Red or Color.Green. You would need a separate variable for each potential color used.
        Last edited by NinjaTrader_RyanM1; 03-31-2011, 02:39 PM.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Many thanks Ryan, think I had over-thought it!

          Cheers, Alan

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          648 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          369 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          108 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          572 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          574 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X