BuySell Pressure
Previous Topic  Next Topic 

Definition
More information...

Syntax
BuySellPressure()
BuySellPressure(IDataSeries inputData)

Returns buy pressure value
BuySellPressure().BuyPressure[int barsAgo]
BuySellPressure(IDataSeries inputData).BuyPressure[int barsAgo]

Returns sell pressure value
BuySellPressure().SellPressure[int barsAgo]
BuySellPressure(IDataSeries inputData).SellPressure[int barsAgo]


Return Type
double; Accessing this method via an index value [int barsAgo] returns the indicator value of the referenced bar. Value range between 0 and 100 representing a percentage.


Parameters

inputData

Indicator source data (?)


Important Tips!
1. This indicator only calculates relevant values on real-time active data. This is since it needs current bid/ask data to determine the buying/selling pressure.
2. This indicator will return constant values of 50 on historical data and therefore its of no value in a historical back test.
3. This indicator MUST have it's 'CalculateOnBarClose' property set to false otherwise buying/selling pressure will not be accurately calculated.
4. You should only use this indicator when coding NinjaScript objects manually and not using the Strategy Wizard.


Examples

// Initialize method
protected override void Initialize()
{
    // You have to set this specific indicator's CalculateOnBarClose property
    // to false if the strategy, indicator or Quote Board Column's CalculateOnBarClose
    // property is set to true, otherwise  the indicator will not calculate it's values
    BuySellPressure().CalculateOnBarClose = false;
}

// OnBarUpdate method
protected override void OnBarUpdate()
{
    // Looking for a long breakout signal
    if (Close[0] > DonchianChannel(20).Upper[5])
    {
        // !! See notes below !!
        if (Historical || BuySellPressure().BuyPressure[0] > 70)
            EnterLong();
    }
}

// !! Since this indicator operates in a real-time environment, you must take special
// care in coding your strategy so that it is only evaluated in in real-time and not
// in a backtest on historical data. In the above example, we check for our breakout
// long signal but we also want to make sure that the breakout bar saw 70% or more
// of its trades hit the ask or higher. 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 BuyPressure condition.


Source Code
You can open up the indicator source code via the NinjaScript Editor.