NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM 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 > General Programming

General Programming General NinjaScript programming questions.

Reply
 
Thread Tools Display Modes
Old 01-03-2007, 02:20 AM   #1
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

In a NinjaScriptindicator or strategy, you add plots via the Add() method:

For example:
Quote:
protected override void Intialize()
{
Add(new Plot(Color.Green, "Plot1"));
Add(new Plot(Color.Red, "Plot2"));
}
Plots are automatically added to the Plots array. You can access individual plot objects and modify properties on them through this array.

The example code belowswitches the entire "Plot1" color betweengreen and red depending on the SMA values:
Quote:
protected override void OnBarUpdate()
{
if (SMA(5)[0] > SMA(15)[0])
Plots[0].Pen.Color = Color.Green;
else
Plots[0].Pen.Color = Color.Red;
}
NinjaTrader_Ray is offline  
Reply With Quote
Old 04-01-2007, 11:02 AM   #2
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Post imported post

Does this approach work? I was under the impression that you had to "set" different plots of different colors to dynamically change colors.

Regards,

Whitmark
whitmark is offline  
Reply With Quote
Old 04-01-2007, 12:27 PM   #3
OUFan
Junior Member
 
Join Date: Feb 2007
Location: , ,
Posts: 14
Thanks: 0
Thanked 0 times in 0 posts
Post imported post

I tried this method and couldn't get it to work. What else needs to be done to make it work?

OUFan




OUFan is offline  
Reply With Quote
Old 04-02-2007, 01:00 AM   #4
NinjaTrader_Ray
Administrator
 
NinjaTrader_Ray's Avatar
 
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,163
Thanks: 6
Thanked 45 times in 32 posts
Post imported post

Yes, this works for changing the "entire" plot color. This is not a solution for a multi-colored plot.

Ray
NinjaTrader_Ray is offline  
Reply With Quote
Old 04-02-2007, 01:25 AM   #5
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Post imported post

Okay, for the record then, the initial example works and is useful to understand how plots work but is not a practical example. The typical application of this type of example ismulti-color plot. . . NinjaScipt newbies take heed.
whitmark is offline  
Reply With Quote
Old 06-23-2007, 11:30 AM   #6
whitmark
Certified NinjaScript Consultant
 
Join Date: Nov 2005
Location: Virginia, USA
Posts: 441
Thanks: 0
Thanked 12 times in 7 posts
Send a message via Skype™ to whitmark
Default

For the sake of clarification, there is a comment earlier in this thread that implies that the Add() method can be used within a NinjaScript strategy to add a Plot. This is not the case. The Add() method, when used with a strategy, can be used add an indicator (that may have its own plot) or another bars object (that will not display), but the Add(Plot) or Add(Line) is currently only reserved for NinjaScript indicators.
whitmark 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


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