Thanks
public class aaVolumetestChris : Indicator { private int activeBar = 0; protected override void OnStateChange() { if (State == State.SetDefaults) { Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDe scriptionBuySellVolume; Name = "aaVolumetestChris"; BarsRequiredToPlot = 1; Calculate = Calculate.OnEachTick; DrawOnPricePanel = true; IsOverlay = true; DisplayInDataBox = true; } else if (State == State.Historical) { if (Calculate != Calculate.OnEachTick) { Draw.TextFixed(this, "NinjaScriptInfo", string.Format(NinjaTrader.Custom.Resource.NinjaScr iptOnBarCloseError, Name), TextPosition.BottomRight); Log(string.Format(NinjaTrader.Custom.Resource.Ninj aScriptOnBarCloseError, Name), LogLevel.Error); } } } protected override void OnMarketData(MarketDataEventArgs e) { if(e.MarketDataType == MarketDataType.Last) { if(e.Price >= e.Ask) buys += (Instrument.MasterInstrument.InstrumentType == Cbi.InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume(e.Volume) : e.Volume); else if (e.Price <= e.Bid) sells += (Instrument.MasterInstrument.InstrumentType == Cbi.InstrumentType.CryptoCurrency ? Core.Globals.ToCryptocurrencyVolume(e.Volume) : e.Volume); } } protected override void OnBarUpdate() { if (CurrentBar < activeBar || CurrentBar <= BarsRequiredToPlot) return; if (CurrentBar != activeBar) { activeBar = CurrentBar; } if (buys > sells) { Draw.Dot(this, "buyers", true, 0, High[0] + TickSize, Brushes.Lime); RemoveDrawObject("sellers"); //Buys[0] = buys; //+sells; } if (buys < sells) { Draw.Dot(this, "sellers", true, 0, Low[0] - TickSize, Brushes.Red); RemoveDrawObject("buyers"); //Sells[0] = sells; } }
Comment