Let me create a simplified table to explain:
I did not mix Bid & Asks events in the table, so let you suppose that there were only Bids or Asks in the example to make the BuySellVolume sum.
As you can see, the BuySell indicator is permanently lagging the Volume bar by 1 tick, and the last tick volume (4 on the tick #4 of currentbar #0) is disappearing when the Currentbar is moving to a new bar.
I never realized that until I was attentively watching "On Market Data" during ETH (slower activity).
I suppose this could be same with the NT7 indicators using OnMarketData.
I'm using NT8 and here below the BuySellVolume code for a reminder:
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) return; Sells[0] = sells; Buys[0] = buys + sells; // Reset accumulators on new bar if (CurrentBar != activeBar) { buys = 0; sells = 0; activeBar = CurrentBar; } }
So there are 2 issues I'm posting here :
1) Volume (buys+sells) not (historically) corresponding to the Bar Volume:
I'm suggesting the following code to improve the indicator
Sells[CurrentBar - activeBar] = sells; Buys[CurrentBar - activeBar] = buys + sells;
When CurrentBar & activeBar are temporarely (before the reset code part at the end) not equal, CurrentBar-activeBar = 1 and still adds the last tick volume to the previous bar [1]. This is possible because of the 1-tick lag in the code operations.
2) Permanent 1-tick lag when the indicator is displayed in real-time:
I'm not a C# programmer and I humbly program NT8 as an amateur for building my own sery of indicators.
I did not find any solution for this 2nd issue, but maybe someone smarter could explain (in familiar language) if it's possible or not to solve this issue.
Thanks
Comment