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 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 md4866, 05-01-2024, 08:15 PM
          2 responses
          17 views
          0 likes
          Last Post md4866
          by md4866
           
          Started by samish18, Today, 12:20 PM
          0 responses
          6 views
          0 likes
          Last Post samish18  
          Started by thread, 04-15-2024, 11:58 PM
          3 responses
          48 views
          0 likes
          Last Post Georg1o
          by Georg1o
           
          Started by leojimenezp, 04-20-2024, 05:49 PM
          4 responses
          49 views
          0 likes
          Last Post leojimenezp  
          Started by nicthe, Today, 09:24 AM
          1 response
          6 views
          0 likes
          Last Post nicthe
          by nicthe
           
          Working...
          X