I've got a multi-granularity strategy that uses a indicator of another indicator in the second granularity.
It appears that adding the indicator as an IDataSeries is causing the update policy to change for all the indicators in the strategy.
Is there anyway you know of to avoid this and keep the indicator as an IDataSeries?
namespace NinjaTrader.Strategy { public class UpdateIssue : Strategy { private IDataSeries indicator; protected override void Initialize() { Add(BarsPeriod.Id,5); CalculateOnBarClose = true; } protected override void OnStartUp() { ClearOutputWindow(); // indicator = SMA(Closes[1],8); indicator = SMA(BarChange(Closes[1]),8); } protected override void OnBarUpdate() { if (BarsInProgress != 0) return; DateTime barTime = Times[BarsInProgress][0]; string time = string.Format("{0:g}\t{1:0.00}",barTime,Closes[1][0]); string test1 = string.Format("\t{0:0.00}",BarChange(Closes[1])[0]); string test2 = string.Format("\t{0:0.00}",SMA(BarChange(Closes[1]),8)[0]); string test3 = string.Format("\t{0:0.00}",indicator[0]); Print(time + test1 + test2 + test3); } } }
2/10/2011 3:52 PM 132.41 0.16 0.07 0.07 2/10/2011 3:53 PM 132.41 0.16 0.08 0.08 2/10/2011 3:54 PM 132.41 0.16 0.10 0.10 2/10/2011 3:55 PM 131.99 -0.43 0.05 0.05 2/10/2011 3:56 PM 131.99 -0.43 -0.01 -0.01 2/10/2011 3:57 PM 131.99 -0.43 -0.06 -0.06 2/10/2011 3:58 PM 131.99 -0.43 -0.13 -0.13 2/10/2011 3:59 PM 131.99 -0.43 -0.21 -0.21
indicator = SMA(Closes[1],8); // indicator = SMA(BarChange(Closes[1]),8);
2/10/2011 3:52 PM 132.41 0.16 0.05 132.19 2/10/2011 3:53 PM 132.41 0.16 0.05 132.19 2/10/2011 3:54 PM 132.41 0.16 0.05 132.19 2/10/2011 3:55 PM 131.99 -0.43 -0.01 132.18 2/10/2011 3:56 PM 131.99 -0.43 -0.01 132.18 2/10/2011 3:57 PM 131.99 -0.43 -0.01 132.18 2/10/2011 3:58 PM 131.99 -0.43 -0.01 132.18 2/10/2011 3:59 PM 131.99 -0.43 -0.01 132.18
Comment