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 bortz, 11-06-2023, 08:04 AM
          47 responses
          1,607 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Today, 05:56 PM
          0 responses
          9 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          19 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          6 views
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          16 views
          0 likes
          Last Post Javierw.ok  
          Working...
          X