OPEN-SOURCE SCRIPT

Statistics plot

1. setting the price range
At the beginning of the script, set the price range (interval). Price ranges are used to divide prices into several groups (buckets) and record how many prices have been reached within each group. For example, setting the price range to “10” will divide the price into intervals 0-10, 10-20, 20-30, and so on.
The price range can also be set manually by the user or automatically calculated based on the initial price. This allows for flexibility in adjusting price ranges for different assets and different time frames.
2. aggregate the number of times a price is reached
Record how many times the price reached each price range (e.g., 100-110, 110-120, etc.). This aggregate data is stored in a data structure called an array.
Each element of the array corresponds to a price range, and when a price reaches that range, the corresponding array value is incremented by one. This process is performed in real time, tracking price movements.
3. initializing and extending price ranges
The first bar of the script (when the chart is first loaded) divides the price ranges into several groups and initializes a count of 0 for each range.
When a price reaches a new range, the array is expanded as needed to add the new price range. This allows the script to work with any price movement, even if the price range continues to grow.
4. visualize the number of price arrivals with a histogram
The aggregated number of arrivals per price range is visually displayed in the form of a histogram. This histogram is designed to allow the user to see at a glance which price range is being reached most frequently.
For example, if prices frequently reach the 100-110 range, the histogram bar corresponding to that range will appear higher than the other ranges. This allows you to visually identify price “dwell points” or support and resistance levels.
5. display of moving averages
A moving average (MA) of the number of times a price has been reached is drawn above the histogram. Moving averages are indicators that show a smooth trend for the number of price arrivals and are useful for understanding the overall direction of price movements.
The duration of the moving average (how many data points it is calculated based on) can be set by the user. This allows for flexible analysis of short or long term price trends. 6.
6. price range tracking and labeling
The script keeps track of which price range the current price is located in. Based on this, information related to the current price range is displayed on the chart as labels.
In particular, labels indicate the beginning and end points of the price range, including which range the price was in at the beginning and which range the price reached at the end. These labels are a useful feature to visually identify price ranges on the chart.
7. labeling of current price range
To confirm which price range the current price is in, when a price reaches a specific price range, a label corresponding to that price range is displayed. This label indicates the position of the price in real-time, allowing traders to visually track where the current price is in the area.
8. calculating the start and end points of the range
The script calculates the start and end points of a range with a non-zero number of price arrivals to find the minimum and maximum of the range. This calculation allows you to see where prices are concentrated within a range.
9. out-of-range price processing
When a price reaches outside the range, the script automatically adds the array element corresponding to that price range and inserts the data in the appropriate location for the count. This allows the script to follow the price as it moves unexpectedly.
statistics

Script de código abierto

Siguiendo fielmente el espíritu de TradingView, el autor de este script lo ha publicado en código abierto, permitiendo que otros traders puedan entenderlo y verificarlo. ¡Olé por el autor! Puede utilizarlo de forma gratuita, pero tenga en cuenta que la reutilización de este código en la publicación se rige por las Normas internas. Puede añadir este script a sus favoritos y usarlo en un gráfico.

¿Quiere utilizar este script en un gráfico?

Exención de responsabilidad