I does not seems to work yet, so tried something easier: collecting volume together.
Basically collect all trades no matter it was bid or ask.
protected override void OnBarUpdate() { totalvol = totalvol + eVol; totalvolplot.Set(totalvol); if(FirstTickOfBar) { totalvol = eVol; } } protected override void OnMarketData(MarketDataEventArgs e) { //Set AskPrice if(e.MarketDataType == MarketDataType.Ask) { AskPrice = e.Price; } //Set BidPrice if(e.MarketDataType == MarketDataType.Bid) { BidPrice = e.Price; } //Trade calculations done on incoming trade data if (e.MarketDataType == MarketDataType.Last) { //Buys calculations if(e.Price >= AskPrice) { eVol = e.Volume; } //Sells calculations if(e.Price <= BidPrice) { eVol = e.Volume; } } } #endregion
Why is that?
Are there any other solution to achieve this?
Comment