NinjaScript > Language Reference > Data >

Volume

Print this Topic Previous pageReturn to chapter overviewNext page

Definition

A collection of historical bar volume values.

 

Property Value

A DataSeries type object. Accessing this property via an index value [int barsAgo] returns a double value representing the volume of the referenced bar.

 

Syntax

Volume
Volume[int barsAgo]

 

 

Examples

// OnBarUpdate method
protected override void OnBarUpdate()
{
    // Is current volume greater than twice the prior bar's volume
    if (Volume[0] > Volume[1] * 2)
         Print("We have increased volume");
 
    // Is the current volume greater than the 20 period moving average of volume
    if (Volume[0] > SMA(Volume, 20)[0])
         Print("Increasing volume");
}