NinjaScript > Language Reference > Indicator Methods >

BuySell Pressure

Print this Topic Previous pageReturn to chapter overviewNext page

Description

The BuySellPressure indicator displays both the current bar's buying and selling pressure as percentage values based on the categorization of trades 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).... Trades in between the market are ignored. This is a real-time indicator only. It functions only on real-time data and therefore does not plot any values on historical data. If you change any property, interval or instrument on a chart, this indicator will restart and any accumulated real-time data plots will be lost.

 

 

Syntax

BuySellPressure()
BuySellPressure(IDataSeries input)

 

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

 

Returns sell pressure value
BuySellPressure().SellPressure[int barsAgo]
BuySellPressure(IDataSeries input).SellPressure[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 (?)

 

 

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 view this indicator method source code by selecting the menu Tools > Edit NinjaScript > Indicator within the NinjaTrader Control Center window.