tick_count

tick_count ( String symbol , Any period , String priceType );

Default values:

symbol: getSymbol() period: "<current period>" priceType: "<current type>"

Description

Returns the number of trades corresponding to an intraday bar. You can use both Aggregation Period constants and pre-defined string values (e.g., 1 min, 2 hours, etc.) as valid parameters for the aggregation period. The full list of the pre-defined string values can be found in the Referencing Secondary Aggregation article. Note that this function is only supported on intraday charts, thus you cannot use aggregations greater than or equal to 1 Day.

Valid parameters for the price type are: LAST, ASK, BID, and MARK. Alternatively, you can use the PriceType constants.

Note that for non-Forex symbols, the last three are only supported on intraday charts with time interval not greater than 15 days.

Input Parameters

Parameter Default value Description
symbol current symbol Defines symbol for which the number of trades is returned.
period current aggregation Defines aggregation period for which the number of trades is returned. Only intraday aggregations are allowed.
priceType current price type The type of price to be taken into account. Choosing LAST will have the function return the number of trades, while choosing MARK, BID, or ASK will have it count changes in quotes of the corresponding price type.

Example

declare lower;

declare zerobase;
plot TradeCount = tick_count;
plot AvgTradeCount = Average(TradeCount, 50);
TradeCount.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
TradeCount.AssignValueColor(if TradeCount >= AvgTradeCount then Color.UPTICK else Color.DOWNTICK);

On an intraday chart, this script plots a histogram that represents the number of trades for each bar along with its simple moving average over 50 bars. If the number of trades is greater than its average, the histogram is displayed in uptick color; otherwise, the downtick color is used.