The codee backtests fine, but in simulated trading or using replay data it goes crazy.
Here is the Start of the strategy:
namespace NinjaTrader.Strategy { /// <summary> /// Test /// </summary> [Description("Test")] public class Test : Strategy { #region Variables #endregion /// <summary> /// This method is used to configure the strategy and is called once before any strategy method is called. /// </summary> protected override void Initialize() { //Add Signals Add(MySignals(TrendStength,TrendPeriod)); VOL().Panel = 2; VOLMA(25).Panel = 2; Add(VOL()); Add(VOLMA(25)); Add(HMA(TrendPeriod)); CalculateOnBarClose = true; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnBarUpdate() { if (Bars.FirstBarOfSession && FirstTickOfBar) { tickValue = Math.Round(Instrument.MasterInstrument.PointValue * TickSize, 2); //Value of a Tick Print(Time[0].ToString() + " TickSize is: " + TickSize + " and TickValue is : " + tickValue); } Print(Time[0].ToString() + "Test values: Bear: " + MySignals(TrendStength, TrendPeriod).Bear[0] + " and Bull: " + MySignals(TrendStength, TrendPeriod).Bull[0]); etc.....
I would expect the second Print Statement to be called once per minute (for each 1 minute bar update), but this is a snipnet of the log that is being produced, so I have no idea of what is happening here? It seems it being called each Tick, when clearly the strategy is stating that it should on close of the bar.
2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0 2/19/2009 12:08:00 PM Test values: Bear: 0 and Bull: 0
Comment