BuySell Volume

View as Markdown

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.

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

ParameterDescription
inputIndicator source data (Series<T>)

Examples

1protected override void OnStateChange()
2{
3 if (State == State.SetDefaults)
4 {
5 // Indicators will inherit the Calculate mode from the hosting script.
6 // Since BuySellVolume requires the use of Calculate.OnEachTick, we must ensure the hosting script has this Calculate mode set
7 Calculate = Calculate.OnEachTick;
8 }
9}
10
11protected override void OnBarUpdate()
12{
13 // This checks that 5,000 or more of the volume hit the bid or lower
14 if (State == State.Historical || BuySellVolume().Sells[0] > 5000)
15 {
16 EnterLong();
17 }
18}

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 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.