PDA

View Full Version : 2 indicators in strategy, only 1 plots...


dhunnewell
03-10-2010, 07:57 AM
The indicators are identical except for name, I have checked the vars via Print() and all looks good, however MACDrossSlow does not plot.

Here is the strategy script:

if (CurrentBar == 0)
{
MACDCrossFast().fastEma.Set(Input[0]);
MACDCrossFast().slowEma.Set(Input[0]);
MACDCrossFast().Value.Set(0);
MACDCrossFast().Avg.Set(0);
MACDCrossFast().Diff.Set(0);
MACDCrossSlow().fastEma.Set(Input[0]);
MACDCrossSlow().slowEma.Set(Input[0]);
MACDCrossSlow().Value.Set(0);
MACDCrossSlow().Avg.Set(0);
MACDCrossSlow().Diff.Set(0);
}
else
{
if(BarsInProgress == fastseries)
{
MACDCrossFast().fastEma.Set((2.0 / (1 + Fast)) * Input[0] + (1 - (2.0 / (1 + Fast))) * MACDCrossFast().fastEma[1]);
MACDCrossFast().slowEma.Set((2.0 / (1 + Slow)) * Input[0] + (1 - (2.0 / (1 + Slow))) * MACDCrossFast().slowEma[1]);

macd = MACDCrossFast().fastEma[0] - MACDCrossFast().slowEma[0];
macdAvg = (2.0 / (1 + Smooth)) * macd + (1 - (2.0 / (1 + Smooth))) * MACDCrossFast().Avg[1];

MACDCrossFast().Value.Set(macd);
MACDCrossFast().Avg.Set(macdAvg);
MACDCrossFast().Diff.Set(macd - macdAvg);
}
if(BarsInProgress == slowseries)
{
MACDCrossSlow().fastEma.Set((2.0 / (1 + Fast)) * Input[0] + (1 - (2.0 / (1 + Fast))) * MACDCrossSlow().fastEma[1]);
MACDCrossSlow().slowEma.Set((2.0 / (1 + Slow)) * Input[0] + (1 - (2.0 / (1 + Slow))) * MACDCrossSlow().slowEma[1]);

macd = MACDCrossSlow().fastEma[0] - MACDCrossSlow().slowEma[0];
macdAvg = (2.0 / (1 + Smooth)) * macd + (1 - (2.0 / (1 + Smooth))) * MACDCrossSlow().Avg[1];

MACDCrossSlow().Value.Set(macd);
MACDCrossSlow().Avg.Set(macdAvg);
MACDCrossSlow().Diff.Set(macd - macdAvg);
}
}


Here is an indicator script:


protected override void Initialize()
{
Add(new Plot(Color.Green, PlotStyle.Dot, "Macd"));
Add(new Plot(Color.Black, "Avg"));
Add(new Plot(new Pen(Color.Navy, 2), PlotStyle.Bar, "Diff"));
Add(new Line(Color.DarkGray, 0, "ZeroLine"));
fastEma = new DataSeries(this);
slowEma = new DataSeries(this);
}


There is no code for OnBarUpdate() in indicators.
Both plot if I use the default series for both.
Hmm... Neither plot using series 1, but the Print() reprsents the values properly...
here is the script that creates the series:

PeriodType ID = BarsPeriod.Id;
int VAL = BarsPeriod.Value;
Print(ID+", "+VAL);
Add(ID,VAL*2);//Scale 1
Add(ID,VAL*4);//Scale 2
Add(ID,VAL*8);//Scale 3
Add(ID,VAL*16);//Scale 4
Add(ID,VAL*32);//Scale 5
Add(ID,VAL*64);//Scale 6
Add(ID,VAL*128);//Scale 7
Add(ID,VAL*256);//Scale 8
Add(ID,VAL*512);//Scale 9
Add(ID,VAL*1024);//Scale 10
Add(ID,VAL*4096);//Scale 11

NinjaTrader_Bertrand
03-10-2010, 08:36 AM
dhunnewell, is this for NT 65 or NT 7 beta?

Do you see any log errors as this occurs?

Thanks

dhunnewell
03-10-2010, 08:39 AM
6.5 No errors, I hve a feeling it is a scope prob, my values are calculated properly from the correct data series... but if that series is not 0 then no plot.

NinjaTrader_Bertrand
03-10-2010, 08:48 AM
Any way you could send me the full export to test on my end? NT 6.5 would not allow for MultiSeries plotting per default.

One thing I spot that's not supported codewise, is dynamically adding the bars periods as well as accessing the BarsPeriod in the Initialize() of the code.

dhunnewell
03-10-2010, 08:53 AM
Yeah, all that occurred to me, however I can print the data for the plots and it is correct, IE: The values for 'macd' and 'macdAvg' are correct. How would you like me to send export? Also the dynamic creation of the series is working fine! Perhaps a trick you can pass on?

NinjaTrader_Bertrand
03-10-2010, 09:03 AM
You can send the exported script to support at ninjatrader dot com Attn Bertrand, I'll then take a look.

Yes, the dynamic adding of bars objects might work as you have found, but it's still unfortunately not supported.

dhunnewell
03-10-2010, 09:14 AM
I cannot find an email and cannot attach the file via support request.
Oh OK, the 'at' went down the wrog pipe.

NinjaTrader_Bertrand
03-10-2010, 10:01 AM
Thanks, got the file, will take a look shortly.