Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using a string to pass Corlor to a drawObject.

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

    Using a string to pass Corlor to a drawObject.

    I am trying to use a string to pass the color property to a draw object but its not liking it, how can I achieve this?

    Here is what I have:-

    Code:
    if(CurrentBar - Convert.ToInt32(drawArray[3,j]) >= lookBack3 * barsInDay)
    					{
    						boxColor = "red";
    					}
    					else if(CurrentBar - Convert.ToInt32(drawArray[3,j]) >= lookBack2 * barsInDay)
    					{
    						boxColor = "green";
    					}
    					else if(CurrentBar - Convert.ToInt32(drawArray[3,j]) >= lookBack1 * barsInDay)
    					{
    						boxColor = "yellow";
    					}
    					
    					DrawRectangle("up"+drawArray[1,i]+drawArray[2,i],CurrentBar - Convert.ToInt16(drawArray[3,i]),drawArray[1,i],0,drawArray[2,i],Color.boxColor);

    #2
    GKonheiser, I would make it simpler and just set boxColor to your color needed. i.e. Color.Red... and then call only boxColor in your Draw method call.

    Comment


      #3
      Hi Bertrand,

      I tryed that,
      Code:
      if(CurrentBar - Convert.ToInt32(drawArray[3,j]) >= lookBack3 * barsInDay)
      					{
      						boxColor = "Color.Red";
      					}
      
      DrawRectangle("up"+drawArray[1,j]+drawArray[2,j],CurrentBar-Convert.ToInt32(drawArray[3,j]),drawArray[1,j],0,drawArray[2,j],boxColor);
      but get the error,

      Argument '6': cannot convert from 'string' to 'System.Drawing.Color'

      Comment


        #4
        boxColor should be of type Color and not string here. Then it should accept it.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        27 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        17 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        9 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        10 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        17 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X