Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to store a color in a variable?

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

    How to store a color in a variable?

    How can I store a color in a variable?

    Variable1 = Color.Red
    Varisble2 = Color.Blue

    thank you.

    #2
    Originally posted by Ironman9973 View Post
    How can I store a color in a variable?

    Variable1 = Color.Red
    Varisble2 = Color.Blue

    thank you.
    Just as you do for all variables. You declare it, and then you use it.
    Code:
    Color Variable1 = Color.Red;

    Comment


      #3
      Thank you. But I cannot use it like:

      Color.Variable1

      I would like to code an indicator where you can input the color of an arrow.

      variable1 = Red
      variable2 = Blue

      DrawArrowDown("tag1" + CurrentBar,true,0,High[0], Color.variable1);

      I hope that makes sense.

      Thank you.

      Comment


        #4
        Originally posted by Ironman9973 View Post
        Thank you. But I cannot use it like:

        Color.Variable1

        I would like to code an indicator where you can input the color of an arrow.

        variable1 = Red
        variable2 = Blue

        DrawArrowDown("tag1" + CurrentBar,true,0,High[0], Color.variable1);

        I hope that makes sense.

        Thank you.
        You need to read up on variables and how they are declared and used. If you have declared Variable1 as a color, why are you referring to it using object notation, as if the declared variable is a member of the Color class: it is an instance of it, not a member.

        Correct is:
        Code:
        Color Variable1 = Color.Red;
        //...
        DrawArrowDown("tag1" + CurrentBar,true,0,High[0], Variable1);

        Comment


          #5
          Thank you.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          157 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          91 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          143 views
          2 likes
          Last Post CaptainJack  
          Started by CarlTrading, 03-30-2026, 11:51 AM
          0 responses
          131 views
          1 like
          Last Post CarlTrading  
          Started by CarlTrading, 03-30-2026, 11:48 AM
          0 responses
          107 views
          0 likes
          Last Post CarlTrading  
          Working...
          X