編輯精選
PINE LIBRARY

Count

5 320
█  OVERVIEW


A library of functions for counting the number of times (frequency) that elements occur in an array or matrix.


█ USAGE


Import the Count library.
Pine Script®

Create an array or matrix that is a `float`, `int`, `string`, or `bool` type to count elements from, then call the count function on the array or matrix.
Pine Script®

The "count map" will return a map with keys for each unique element in the array or matrix, and with respective values representing the number of times the unique element was counted. The keys will be the same type as the array or matrix counted. The values will always be an `int` type.
Pine Script®

If an array is in ascending or descending order, then the keys of the map will also generate in the same order.
Pine Script®

Include a value to get the count of only that value in an array or matrix.
Pine Script®

The string method of count() can use strings or regular expressions like "bull*" to count all matching occurrences in a string array.
Pine Script®

To count multiple values, use an array of values instead of a single value. Returning a count map only of elements in the array.
Pine Script®

Multiple regex patterns or strings can be counted as well.
Pine Script®

An optional comparison operator can be specified to count the number of times an equality was satisfied for `float`, `int`, and `bool` methods of `count()`.
Pine Script®

When passing an array of values to count and a comparison operator, the operator will apply to each value.
Pine Script®

Multiple comparison operators can be applied when counting multiple values.
Pine Script®

免責聲明

這些資訊和出版物並非旨在提供,也不構成TradingView提供或認可的任何形式的財務、投資、交易或其他類型的建議或推薦。請閱讀使用條款以了解更多資訊。