It would appear Bars.TickCount doesn't do what it is supposed to do ...
... from the NinjaTrader 7 Help:
TickCount
Definition
The total number of ticks of the current bar.
Property Value
A int value that represents the total number of ticks of the current bar.
Syntax
Bars.TickCount
I have run the following strategy on a variety of timeframes ... it seems that Bars.TickCount currently returns BarsPeriod.Value (ie., for a 5min chart, it returns 5, for a 250-volume chart, it returns 250, etc.).
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Indicator;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Strategy;
#endregion
// This namespace holds all strategies and is required. Do not change it.
namespace NinjaTrader.Strategy
{
/// <summary>
///
/// </summary>
[Description("")]
public class DemoTickCountBug : Strategy
{
#region Variables
// Wizard generated variables
// User defined variables (add any user defined variables below)
int _MinTickCount;
int _MaxTickCount;
#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()
{
_MinTickCount = 0;
_MaxTickCount = 0;
CalculateOnBarClose = true;
}
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (_MinTickCount == 0)
_MinTickCount = Bars.TickCount;
_MinTickCount = Math.Min( _MinTickCount, Bars.TickCount );
_MaxTickCount = Math.Max( _MaxTickCount, Bars.TickCount );
Print("Bar# " + CurrentBar + " TickCount : " + Bars.TickCount + " - MinTickCount : " + _MinTickCount + " - MaxTickCount : " + _MaxTickCount );
}
#region Properties
#endregion
}
}
Comment