View Full Version : Changing line color based on indicator
ssg10
05-13-2009, 02:18 AM
I tried to change line color using the following but it won't change. Any idea?
protectedoverridevoid Initialize()
{
Add(new Plot(Color.Orange, PlotStyle.Line, "L2"));
...
}
....
if(Close[0] < (currentLow+todayFlip) && Close[0] < priordayClose)
{
Print("red");
Plots[0].Pen = new Pen(Color.Red);
}
else
{
Print("blue");
Plots[0].Pen = new Pen(Color.Blue);
}
mrlogik
05-13-2009, 05:17 AM
ssg10,
as of now, you cannot do it in that fashion. I believe this changes in NT 7.0.
Either way, you have to have a new plot for each color,
so to get what you want...
protectedoverridevoid Initialize()
{
Add(new Plot(Color.Red, PlotStyle.Line, "L2c1"));
Add(new Plot(Color.Blue, PlotStyle.Line, "L2c2"));
...
}
....
if(Close[0] < (currentLow+todayFlip) && Close[0] < priordayClose)
{
Print("red");
//set L2c1 here
L2c1.Set(somevalue);
//if its a LINE plot, you may have to connect the two depending on your application
L2c1.Set(1, somevalue[1]);
}
else
{
//set L2c2 here
L2c2.Set(somevalue);
//if its a LINE plot, you may have to connect the two depending on your application
L2c2.Set(1, somevalue[1]);
}
I believe there is an NT reference sample of this.
NinjaTrader_Bertrand
05-13-2009, 05:51 AM
Thanks for the help mrlogik, here's the reference sample for multicolored plots ssg10 - http://www.ninjatrader-support2.com/vb/showthread.php?t=3227
ssg10
05-13-2009, 04:22 PM
Thanks!
How do we refer to the plot object to change its property?
Add(new Plot(Color.Red, PlotStyle.Line, "L2c1"));
will L2c1.Set work, because we define above "L2c1" ?
ssg10
05-13-2009, 04:27 PM
From the sample code provided, I got a question.
RisingPlot.Set(1, SMA(Period)[1]);
Where is RisingPlot object created?
roonius
05-13-2009, 06:19 PM
From the sample code provided, I got a question.
RisingPlot.Set(1, SMA(Period)[1]);
Where is RisingPlot object created?
It's a property of a your indicator class
eDanny
05-14-2009, 07:03 AM
Thanks!
How do we refer to the plot object to change its property?
Add(new Plot(Color.Red, PlotStyle.Line, "L2c1"));
will L2c1.Set work, because we define above "L2c1" ?
Since you have added this Plot in the first spot it can be referred to as Values[0]. If it is defined as "L2c1" in your Properties section you can then call it by that name.
NinjaTrader_Bertrand
05-14-2009, 07:11 AM
ssg10, please expand the properties section of the SampleMultiColoredPlot script, then you see the 'linking' of RisingPlot to Values[0] and so on for the other ones...