PDA

View Full Version : Adding Plots


rt-trader
02-07-2007, 04:11 PM
I am having a problem adding extra Plot Lines to an existing Indicator.

I have used the Add method for the lines and also included the extra DataSeries decalartions in Properties.

What happens is the first 3 Plots (from the original indicator) draw Ok on the chart until I addPlotx.Set(xx); then they disappear and the new Plots dont plot either.

I have verified that the extra values I wish to Plot are calculating OK by substituting them into the 3 Plots that work

Is there something else I need to do - or is the a limit on the number of lines that can be plotted on a chart? ( I need 9).

Thanks for any help or suggestions...

NinjaTrader_Ray
02-08-2007, 12:51 AM
There is no limits on the number of plots you can have in an indicator. Do you see any errors in the log tab when the plots are not visible? Do these plots completely disappear?

rt-trader
02-08-2007, 04:10 AM
Thankyou for the reply.

Yes there was an error in the log tab which I had missed

"Error on calling 'OnBarUpdate' method for indicator xxx on bar 0: Index was outside the bounds of the array."

The error occurs whenever the extra Plots are included - and then the existing lines disappear as well - probably as a result of the error.

I have tried regeneratinga new wizard script from scratch and it works fine. However whenI add in extra Plot lines ( and update properties accordingly) the new lines do not plot.There is no error in log tab within this new script.

There must be something very basic I am missing here. When adding new Plot lines, what steps need to be taken beyond

1. Add(new Plot(Color.Yellow, PlotStyle.Line, "Name"); and

2. Update Properties with

[Browsable(false)]

[XmlIgnore]

public DataSeries Name

{

get { return Values[4]; }

}

Thanks

NinjaTrader_Ray
02-08-2007, 04:26 AM
Yes, likey something basic. Please look at sample code below. This works.



/// <summary>



/// This method is used to configure the indicator and is called once before any bar data is loaded.



/// </summary>



protected override void Initialize()

{

Add(new Plot(Color.Orange, PlotStyle.Line, "Plot0"));

Add(new Plot(Color.Green, PlotStyle.Line, "Plot1"));

Add(new Plot(Color.DarkViolet, PlotStyle.Line, "Plot2"));

Add(new Plot(Color.Firebrick, PlotStyle.Line, "Plot3"));

Add(new Plot(Color.AliceBlue, PlotStyle.Line, "Plot4"));

Add(new Plot(Color.Blue, PlotStyle.Line, "Plot5"));

Add(new Plot(Color.Brown, PlotStyle.Line, "Plot6"));

Add(new Plot(Color.Violet, PlotStyle.Line, "Plot7"));

Add(new Plot(Color.Crimson, PlotStyle.Line, "Plot8"));

Add(new Plot(Color.DarkGoldenrod, PlotStyle.Line, "Plot9"));

Add(new Plot(Color.DarkOliveGreen, PlotStyle.Line, "Plot10"));

CalculateOnBarClose = true;

Overlay = true;

PriceTypeSupported = false;

}

/// <summary>



/// Called on each bar update event (incoming tick)



/// </summary>



protected override void OnBarUpdate()

{

Plot0.Set(SMA(10)[0]);

Plot1.Set(SMA(15)[0]);

Plot2.Set(SMA(20)[0]);

Plot3.Set(SMA(25)[0]);

Plot4.Set(SMA(30)[0]);

Plot5.Set(SMA(35)[0]);

Plot6.Set(SMA(40)[0]);

Plot7.Set(SMA(45)[0]);

Plot8.Set(SMA(50)[0]);

Plot9.Set(SMA(55)[0]);

Plot10.Set(SMA(60)[0]);

}

#region Properties

[Browsable(false)]

[XmlIgnore()]

public DataSeries Plot0

{

get { return Values[0]; }

}

[Browsable(false)]

[XmlIgnore()]

public DataSeries Plot1

{

get { return Values[1]; }

}

[Browsable(false)]

[XmlIgnore()]

public DataSeries Plot2

{

get { return Values[2]; }

}

[Browsable(false)]

[XmlIgnore()]

public DataSeries Plot3

{

get { return Values[3]; }

}



[Browsable(false)]

[XmlIgnore()]

public DataSeries Plot4

{

get { return Values[4]; }

}



[Browsable(false)]

[XmlIgnore()]

public DataSeries Plot5

{

get { return Values[5]; }

}



[Browsable(false)]

[XmlIgnore()]

public DataSeries Plot6

{

get { return Values[6]; }

}



[Browsable(false)]

[XmlIgnore()]

public DataSeries Plot7

{

get { return Values[7]; }

}



[Browsable(false)]

[XmlIgnore()]

public DataSeries Plot8

{

get { return Values[8]; }

}



[Browsable(false)]

[XmlIgnore()]

public DataSeries Plot9

{

get { return Values[9]; }

}



[Browsable(false)]

[XmlIgnore()]

public DataSeries Plot10

{

get { return Values[10]; }

}





#endregion

rt-trader
02-08-2007, 10:47 PM
Thankyou for posting the code - I was able to adapt it to what I wanted although not without the same initial difficulty.

Perhaps you could try and reproduce what happened by building any indicator using the wizard which has say3 Plots. Once built try and add 3 more Plots and see if they display properly.

Thanks again for your help.

NinjaTrader_Ray
02-09-2007, 01:01 AM
Thats exactly what I did exceptI added 6 plots.