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 argusthome, 03-08-2026, 10:06 AM
        0 responses
        116 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        61 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        40 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        44 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        82 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X