NinjaTrader Support Forum  

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 11-02-2008, 08:26 AM   #1
SystemTrading
Senior Member
 
Join Date: Aug 2008
Location: Orlando, Florida
Posts: 166
Thanks: 0
Thanked 0 times in 0 posts
Default Dynamic Plot Color

I've followed the example in the help document and I'm having some trouble. I am using the follow code.

Code:
 
protected override void Initialize()
{
Add(new Plot(Color.DarkGray,PlotStyle.Bar,"myplot");
}
 
protected override void OnBarUpdate()
{
if (x && y && z)
Plots[0].Pen= new Pen(Color.Yellow);
 
if (!x && !y && !z)
Plots[0].Pen= new Pen(Color.Blue);
}
For some reason ALL bars on the chart are colored dark gray. Occasionally as I scroll through the chart ALL bars will change yellow or blue, but I am trying to color individual bars as they happen. Am I doing something wrong?
SystemTrading is offline  
Reply With Quote
Old 11-02-2008, 08:53 AM   #2
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,164
Thanks: 6
Thanked 46 times in 32 posts
Default

Yes, you are changing the color of the entire plot (all histogram bars) not just single ones. To do what you want, add X number of plots where X is the number of different colors used. If you want to show color A, set the value only for plot A, if you want to show color b, set the value only for plot B.

Check out the system indicator source code VolumeUpDown for an example of this.
NinjaTrader_Ray is offline  
Reply With Quote
Old 11-02-2008, 09:10 AM   #3
SystemTrading
Senior Member
 
Join Date: Aug 2008
Location: Orlando, Florida
Posts: 166
Thanks: 0
Thanked 0 times in 0 posts
Default

Thanks Ray!
SystemTrading 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
Get the plot/color of the of the previous bar? Ninja B General Programming 3 01-23-2011 10:51 PM
Could you guys please rethink plot color changes hygm General Programming 1 02-11-2008 10:26 PM
Sma To Plot Color Bars Not Lines avlasov Indicator Development 4 12-08-2007 03:37 PM
Dynamic plot coloring ThePatientOne Indicator Development 11 04-02-2007 01:06 AM
Changing Plot color within code tquinn Indicator Development 8 02-19-2007 08:27 AM


All times are GMT -6. The time now is 08:47 PM.