NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Sunday May 26th at 12PM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Indicator Development

Indicator Development Support for the development of custom indicators using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 02-26-2009, 01:40 PM   #1
dwalls
Senior Member
 
Join Date: Jul 2007
Posts: 176
Thanks: 0
Thanked 0 times in 0 posts
Default Shading an Area on a CCI Indicator

Hello,
I am looking for help with shading an area on the CCI.
For example: Shade the area between the +50 and the -50 lines.
Were I could chose a color and opacity.

Thanks for any help.
dwalls is offline  
Reply With Quote
Old 02-26-2009, 02:03 PM   #2
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

dwalls,

Have you tried using DrawRegion()?
NinjaTrader_Josh is offline  
Reply With Quote
Old 02-26-2009, 02:48 PM   #3
dwalls
Senior Member
 
Join Date: Jul 2007
Posts: 176
Thanks: 0
Thanked 0 times in 0 posts
Default

Hi,
Thx Josh.
I have tried this but it wont compile. Any ideas?

{
DrawRegion("Shaded 50", CurrentBar, 0, CCI(14)(50), CCI(14)(-50), Color.Empty, Color.Blue, 2);
}

Is it close?

Thanks
dwalls is offline  
Reply With Quote
Old 02-26-2009, 02:53 PM   #4
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

CCI(14)(50), CCI(14)(-50)
You will need to change these.

CCI(14)[50]

Not sure what you want with -50. You cannot access into the future. If you want it to stop painting within 50 bars into the future you can run an if-statement that keeps redrawing it until 50 bars have passed then stops.
NinjaTrader_Josh is offline  
Reply With Quote
Old 02-26-2009, 03:09 PM   #5
dwalls
Senior Member
 
Join Date: Jul 2007
Posts: 176
Thanks: 0
Thanked 0 times in 0 posts
Default

Thx Josh,
I am trying to shade the area between the 50's like in the attached screenshot. I just used the Rectangle tool to draw the shaded area on the screenshot to show you. Dont I need to use [-50] in there some how?

Thanks
Attached Images
File Type: jpg CCI with Shaded btw the 50's.jpg (42.5 KB, 113 views)
dwalls is offline  
Reply With Quote
Old 02-26-2009, 03:28 PM   #6
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

You need to input that in differently. You need to use an if-statement to determine that the CCI value is between the 50s.

Code:
if (CCI(14)[0] > -50 || CCI(14)[0] < 50)
You need to determine which range you want to color. Do you want CCI to the -50 line or CCI to the 50 line? It becomes a little funky as the CCI flip flops and that is something you will need to work out on your own.
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-19-2009, 08:48 AM   #7
dwalls
Senior Member
 
Join Date: Jul 2007
Posts: 176
Thanks: 0
Thanked 0 times in 0 posts
Default

Thx Josh,
I think I'm being a little misunderstood.
It doesnt really matter where the value of the CCI(14) is at.
It's value would not be a factor in the shading.
I'm just trying to have a permanent/set shade or color in the area between the +50 line and the -50 line on the CCI indicator, as a colored area/zone of caution for example.

Does that make sense.

Thanks for your help.
dwalls is offline  
Reply With Quote
Old 03-19-2009, 08:58 AM   #8
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Use DrawOnPricePanel = false in Initialize() and then shade the range with the appropriate values.
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-19-2009, 09:54 AM   #9
dwalls
Senior Member
 
Join Date: Jul 2007
Posts: 176
Thanks: 0
Thanked 0 times in 0 posts
Default

Thx Josh,
I'm having a hard time with this one, its probably simple and its just me.
Could you please help me with a code example of how shading a range between two values of an indicator would work.
Thanks for your time.
dwalls is offline  
Reply With Quote
Old 03-19-2009, 10:05 AM   #10
NinjaTrader_Josh
NinjaTrader Product Manager
 
NinjaTrader_Josh's Avatar
 
Join Date: May 2007
Location: Denver, CO
Posts: 17,458
Thanks: 1
Thanked 107 times in 70 posts
Default

Please find the attached indicator.
Attached Files
File Type: zip dwalls.zip (5.0 KB, 82 views)
NinjaTrader_Josh is offline  
Reply With Quote
Old 03-19-2009, 02:35 PM   #11
dwalls
Senior Member
 
Join Date: Jul 2007
Posts: 176
Thanks: 0
Thanked 0 times in 0 posts
Default

Thx Josh,
Got it to work now.
Thank you so much for your help and all you guys do in this forum.

dwalls
dwalls is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CCI / Stochastic combo (looking for indicator) TheWizard Indicator Development 8 03-27-2009 01:28 PM
Indicator ploted on CCI zero line dwalls Indicator Development 28 10-23-2008 11:32 AM
Help with code (Zone Shading) tommyjames Indicator Development 16 04-29-2008 02:00 AM
Woodies CCI Indicator KBJ Indicator Development 5 06-24-2007 10:29 AM
Shading areas of chart? higler Charting 3 05-01-2007 07:58 AM


All times are GMT -6. The time now is 02:41 AM.