NexusFi: Find Your Edge


Home Menu

 





Paint charts based on Line crossovers on an oscillator


Discussion in NinjaTrader

Updated
    1. trending_up 1,924 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 3 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
 
KillerJukeBox's Avatar
 KillerJukeBox 
Dublin
 
Experience: Intermediate
Platform: Ninjatrader, Tastytrade
Broker: Ninjatrader Brokerage, IBKR, Tastytrade,
Trading: MNQ,MES. Stocks, Stock options
Posts: 88 since Oct 2018
Thanks Given: 15
Thanks Received: 98

I'm trying to incorporate some rules into a CCI indicator so that it paints my charts a particular colour when certain conditions are met.

Here is the psuedo-code for the rules:

if CCI >=100, paint the chart green.
if CCI >=200 , paint the chart dark green.

if CCI <=-100, paint the chart red.
if CCI <=-200, paint the chart dark red.


This bit works fine, as you can see.


I'm having problems implementing the rule below:

if CCI crossing above -100, continue painting the chart red until it hits either 0 or +100 (set by a variable).
if CCI crossing below +100, continue painting the chart green until it hits either 0 or -100 (set by a variable).


I want to create a rule so that when CCI travels from -100 to +100 (or from +100 to -100) it will continue to paint whatever it was painting previously when it entered that range.

Here is my current code:

VARIABLES:
 
Code
double CurrentCCI = CCI(14)[0];
double PreviousCCI = CCI(14)[1];
double mean = 0;
double sma0 = sma[0];

 
Code
	//Paint Backgrounds according to CCI.
				if(CurrentCCI >=100)
				{
					//BackBrushesAll[1] = Brushes.White; // Repaint 1 bar when we change direction.
						BackBrushAll = iBrushBackUp;
					 if(CurrentCCI >=200)
					{
						BackBrushAll = iBrushCloseLong;
						//BackBrushesAll[1] = Brushes.Gold; //Repaint 1 bar when we change direction.
					} 
					
					
				}
				
				else if(CurrentCCI <=-100)
				{
					BackBrushAll = iBrushBackDown;
					
					 if(CurrentCCI <=-200)
					{
						BackBrushAll = iBrushCloseShort;
					} 
					
				}
What's the best method to describe this rule?

Ive tried the below using some booleans ("bullish","bearish") , but i'm missing something simple I think.

 
Code
if(CurrentCCI <0){
						
						if(bullish == true){
						BackBrushAll = iBrushBackUp;	
						}
						
						if(bearish == true){
							BackBrushAll = iBrushBackDown;
						}
						
						 if(CurrentCCI <=-100)
							 
							{
								BackBrushAll = iBrushBackDown;
								bullish = false;
								bearish = true;
								
											if (CurrentCCI <=-200)
											{
												BackBrushAll = iBrushCloseShort;
												bearish = false;
											}
							}
					}
 
Code
if(CurrentCCI >0){
					
						if(bullish == true){
						BackBrushAll = iBrushBackUp;	
						}
						
						if(bearish == true){
							BackBrushAll = iBrushBackDown;
						}
						
							if(CurrentCCI >=100){
						
					//BackBrushesAll[1] = Brushes.White; // Repaint 1 bar when we change direction.
						BackBrushAll = iBrushBackUp;
						bullish = true;
						bearish = false;
								
								if(CurrentCCI >=200)
								{
									
									BackBrushAll= iBrushCloseLong;
									bullish = false;
								}		
					}
							
					}
Any thoughts welcome!

Ive exported the current version and attached it.


Attached Files
Elite Membership required to download: CCI_Chart_PAINT.zip
Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Kraken Becomes First US Digital Asset Bank With Direct F …
Cryptocurrency
Q1 2026 Shatters All Derivatives Volume Records -- CME H …
Traders Hideout
April 2026 Jobs Report: +115k vs +65k Expected
Traders Hideout
Saylors 41-Month HODL Breaks: Strategy Sells 32 BTC as $ …
Prediction Markets & Event Contracts
Election Sunday Resolves: Peru Heads to Runoff at 42pct, …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Sober Journey With S&P
21 thanks
2026 Jlab journal
10 thanks
Algo automated / semi-automated trading anyone?
6 thanks
Lady Vols Primer: Trading Volatility Journal
6 thanks
2026 Fire Horse
5 thanks
  #3 (permalink)
 
KillerJukeBox's Avatar
 KillerJukeBox 
Dublin
 
Experience: Intermediate
Platform: Ninjatrader, Tastytrade
Broker: Ninjatrader Brokerage, IBKR, Tastytrade,
Trading: MNQ,MES. Stocks, Stock options
Posts: 88 since Oct 2018
Thanks Given: 15
Thanks Received: 98


Nevermind. A good night's sleep makes this obvious again.

Happy Xmas peeps!


Follow me on X Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #4 (permalink)
jsk123
Hyderabad,India
 
Posts: 88 since Oct 2013
Thanks Given: 44
Thanks Received: 21

Good looking chart!!! LOVE IT!!!

Happy Christmas.


Reply With Quote




Last Updated on December 24, 2018


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts