BuySell Volume

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Language Reference > Common > System Indicator Methods >

BuySell Volume

Previous page Return to chapter overview Next page

Description

The BuySellVolume indicator displays a real-time horizontal histogram of volume categorized as buy or sell trades. Trades are categorized in real-time as a buy (at the ask or above) or as a sell (at the bid or below) and then color coded .... Trades in between the market are ignored.

 

Note:  For historical calculations, Tick Replay must be enabled

 

 

Syntax

BuySellVolume()
BuySellVolume(ISeries<double> input)

 

Returns buy volume
BuySellVolume().Buys[int barsAgo]
BuySellVolume(ISeries<double> input).Buys[int barsAgo]

 

Returns sell volume
BuySellVolume().Sells[int barsAgo]
BuySellVolume(ISeries<double> input).Sells[int barsAgo]

 

Return Value

double; Accessing this method via an index value [int barsAgo] returns the indicator value of the referenced bar.

 

 

Parameters

input

Indicator source data (?)

 

 

Example

ns


protected override void OnStateChange()
{
  if (State = State.SetDefaults)
  {
      // You have to set this specific indicator's Calculate property
      // to Calculate.OnEachTick if the strategy, indicator or Quote Board Column's Calculate
      // property is set to true, otherwise the indicator will not calculate it's values
      BuySellVolume().Calculate = Calculate.OnEachTick;
  }
}
 
protected override void OnBarUpdate()
{
  // This checks that 5,000 or more of the volume hit the bid or lower
  if (State == State.Historical || BuySellVolume().Sells[0] > 5000)
  {
      EnterLong();    
  }
}

 

Tip: Since this indicator operates in a real-time environment, remember to check for State.Realtime, or enable Tick Replay on the associated Data Series. In the above example we check that 5,000 or more of the volume hit the bid or lower. Our statement checks if the data is being calculated on historical data first, if true, we enter long, if not true (live), the the statement then checks for the Buy Volume condition.

 

Source Code

You can view this indicator method source code by selecting the menu New > NinjaScript Editor > Indicators within the NinjaTrader Control Center window.