NinjaTrader_Ray
01-16-2007, 07:14 AM
If you want to incorporate some logic to have your indicator or strategy only run on real-time data, then you should incorporate the following.
Checks if bar data is historical or real-time. Ifhistorical, return out of the method.
protected override void OnBarUpdate()
{
if (Historical)
return;
}
If you want to know if the bar being processed is the last bar on the chart.
When CalculateOnBarClose == false, then OnBarUpdate() is being called for the last bar on the chart:
protected override void OnBarUpdate()
{
if (CurrentBar == Bars.Count - 1)
// Is last bar on chart
}
When CalculateOnBarClose == true, then OnBarUpdate() is being called for the last closed bar on the chart, not thein processbar:
protected override void OnBarUpdate()
{
if (CurrentBar== Bars.Count -2)
// Is last bar on chart
}
Ray
Checks if bar data is historical or real-time. Ifhistorical, return out of the method.
protected override void OnBarUpdate()
{
if (Historical)
return;
}
If you want to know if the bar being processed is the last bar on the chart.
When CalculateOnBarClose == false, then OnBarUpdate() is being called for the last bar on the chart:
protected override void OnBarUpdate()
{
if (CurrentBar == Bars.Count - 1)
// Is last bar on chart
}
When CalculateOnBarClose == true, then OnBarUpdate() is being called for the last closed bar on the chart, not thein processbar:
protected override void OnBarUpdate()
{
if (CurrentBar== Bars.Count -2)
// Is last bar on chart
}
Ray