This is an indicator, which in real time separate volume on every Last tick to bulls or bears (if last price = bid - volume is bearish; if last price = ask - volume is bullish)
Here is a code:
int Previous_time; double Previous_Ask, Previous_Bid; double Bulls_Volume, Bears_Volume; /// <summary> /// This method is used to configure the indicator and is called once before any bar data is loaded. /// </summary> protected override void Initialize() { Overlay = true; CalculateOnBarClose = false; } /// <summary> /// Called on each bar update event (incoming tick) /// </summary> protected override void OnMarketData(MarketDataEventArgs e) { if (e.MarketDataType == MarketDataType.Ask) { Previous_Ask = e.Price; Print("Ask = " + e.Price + " " + e.Time); } if (e.MarketDataType == MarketDataType.Bid) { Previous_Bid = e.Price; Print("Bid = " + e.Price + " " + e.Time); } if (e.MarketDataType == MarketDataType.Last) { if(e.Price == Previous_Ask) { Bulls_Volume += e.Volume; } else { Bears_Volume += e.Volume; } /* if(e.Price == Previous_Bid) { Bears_Volume += e.Volume; }*/ //Print("Last = " + e.Price + " " + e.Time + " Volume: " +e.Volume); } } }
Look at this picture:
On some bars a sum of bearish (red color) and bullish (green color) is equals total volume on bar (black color) - and it's exactly correct, but on some bars this sum of bearish and bullish volumes doesn't equal total volume on bar - why it's so?
Comment