Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Background Color / 3. Color

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

    Background Color / 3. Color

    Hello,
    i'd like to color the background of the chart with 3 colors:
    green (if Close > SMA 50)
    yellow ( if Close is between SMA 25 / 50)
    red ( if Close is < than 25)

    green and red is working fine. but i'm struggling with the 3rd color.
    after adding the 3.rd condition everything is yellow....

    i'm using the following code
    Code:
                       //Condition1
    			if (Close[0] < SMA(25) [0] && Close [0] < SMA (50[0])
    			{
    				BackColor = Color.Red;
    			}
    			
    			//Condition 2
    			if (Close [0] > SMA(25) [0 ]&& Close [0] > SMA (50[0])
    			{
    				BackColor = Color.Green;
    			}
    			
    						
    				
    			//Condition 3
    			//if (Close [0] > SMA (25 [0] && Close [0] < SMA(50)[0]);
    			//{
    			//	BackColor = Color.Yellow;
    			//}
    Can someone point me into the right direction pls ?
    thx

    #2
    Originally posted by Tradexxx View Post
    Hello,
    i'd like to color the background of the chart with 3 colors:
    green (if Close > SMA 50)
    yellow ( if Close is between SMA 25 / 50)
    red ( if Close is < than 25)

    green and red is working fine. but i'm struggling with the 3rd color.
    after adding the 3.rd condition everything is yellow....

    i'm using the following code
    Code:
                       //Condition1
    			if (Close[0] < SMA(25) [0] && Close [0] < SMA (50[0])
    			{
    				BackColor = Color.Red;
    			}
    			
    			//Condition 2
    			if (Close [0] > SMA(25) [0 ]&& Close [0] > SMA (50[0])
    			{
    				BackColor = Color.Green;
    			}
    			
    						
    				
    			//Condition 3
    			//if (Close [0] > SMA (25 [0] && Close [0] < SMA(50)[0])[COLOR="red"][B];[/B][/COLOR]
    			//{
    			//	BackColor = Color.Yellow;
    			//}
    Can someone point me into the right direction pls ?
    thx
    You see the semi-colon that I have highlighted in bold red? Remove it. It turns your filter into a null statement, and so the succeeding block always executes.

    Comment


      #3
      Hello Tradexxx,

      Thank you for your inquiry.

      koganam is, indeed, correct.

      Please remove the semicolon after:
      Code:
      if (Close [0] > SMA (25 [0] && Close [0] < SMA(50)[0])[B][COLOR="Red"];[/COLOR][/B]
      Zachary G.NinjaTrader Customer Service

      Comment


        #4
        koganam, zacharyg thank you very much!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by PaulMohn, Today, 05:00 AM
        0 responses
        6 views
        0 likes
        Last Post PaulMohn  
        Started by ZenCortexAuCost, Today, 04:24 AM
        0 responses
        6 views
        0 likes
        Last Post ZenCortexAuCost  
        Started by ZenCortexAuCost, Today, 04:22 AM
        0 responses
        3 views
        0 likes
        Last Post ZenCortexAuCost  
        Started by SantoshXX, Today, 03:09 AM
        0 responses
        16 views
        0 likes
        Last Post SantoshXX  
        Started by DanielTynera, Today, 01:14 AM
        0 responses
        5 views
        0 likes
        Last Post DanielTynera  
        Working...
        X