NexusFi: Find Your Edge


Home Menu

 





Paint charts based on Line crossovers on an oscillator


Discussion in NinjaTrader

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




 
Search this Thread

Paint charts based on Line crossovers on an oscillator

  #1 (permalink)
 
KillerJukeBox's Avatar
 KillerJukeBox 
Dublin
 
Experience: Intermediate
Platform: Ninjatrader, Tastytrade
Broker: Ninjatrader Brokerage, IBKR, Tastytrade,
Trading: MNQ,MES. Stocks, Stock options
Posts: 84 since Oct 2018
Thanks Given: 13
Thanks Received: 95

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 Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Cheap historycal L1 data for stocks
Stocks and ETFs
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
How to apply profiles
Traders Hideout
NexusFi Journal Challenge - May 2024
Feedback and Announcements
Trade idea based off three indicators.
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
What is Markets Chat (markets.chat) real-time trading ro …
75 thanks
Spoo-nalysis ES e-mini futures S&P 500
55 thanks
Just another trading journal: PA, Wyckoff & Trends
36 thanks
Bigger Wins or Fewer Losses?
24 thanks
The Program
16 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: 84 since Oct 2018
Thanks Given: 13
Thanks Received: 95


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

Happy Xmas peeps!

Follow me on Twitter 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


© 2024 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 - Privacy Policy - Downloads - Top
no new posts