first post here. I've started to use NT8 and I'm liking it a lot.
I'm developing my first custom indicator and I'm struggling a bit trying to understand how to use the funcitions onMarketData and onBarUpdate.
The indicator I'm developing uses tick replay. I've started looking into the system indicator BuySellVolume source code.
I see a problem in the code below (from the BuySellVolume indicator)
protected override void OnMarketData(MarketDataEventArgs e)
{
if(e.MarketDataType == MarketDataType.Last)
{
if(e.Price >= e.Ask)
{
buys += e.Volume;
}
else if (e.Price <= e.Bid)
{
sells += e.Volume;
}
}
}
protected override void OnBarUpdate()
{
if (CurrentBar < activeBar || CurrentBar <= BarsRequiredToPlot)
return;
// New Bar has been formed
// - Assign last volume counted to the prior bar
// - Reset volume count for new bar
if (CurrentBar != activeBar)
{
Sells[1] = sells;
Buys[1] = buys + sells;
buys = 0;
sells = 0;
activeBar = CurrentBar;
}
Sells[0] = sells;
Buys[0] = buys + sells;
}
...
if (CurrentBar != activeBar)
{
Sells[1] = sells;
Buys[1] = buys + sells;
buys = 0;
sells = 0;
activeBar = CurrentBar;
}
...
How can we know that onMarketData has added the volumes up to the last tick of the previous bar?

Comment