OPEN-SOURCE SCRIPT
Monthly High/Low - [JTCAPITAL]

Monthly High/Low Probability Table - [JTCAPITAL] is a modified way to use historical monthly high and low tracking combined with probabilistic analysis for bullish and bearish months to detect potential patterns in monthly price behavior.
The indicator works by calculating in the following steps:
Buy and Sell Conditions:
This indicator does not provide direct buy or sell signals. Instead, it provides probabilistic information about historical patterns for bullish and bearish months. Traders can use the table to:
Identify days in the month where highs or lows are statistically more likely to occur.
Combine with other trend-following or reversal strategies to optimize entry and exit points.
For example, if a trader notices that bullish month highs frequently occur around day 15, they may plan trades around that period when other indicators align.
Features and Parameters:
Dynamic Probability Table: Updates in real-time as new monthly data becomes available.
Historical Pattern Tracking: Maintains arrays for highs and lows in bullish and bearish months.
Gradient Visualization: Uses color interpolation to quickly highlight higher probability days.
Specifications:
Monthly High/Low Tracking
Tracks the highest and lowest prices within each month. This is the foundation of the probability calculations. It allows traders to understand when significant price events historically occur.
Bullish/Bearish Month Classification
Each month is classified based on the relationship between monthClose and monthOpen. This provides context for the high/low occurrences: whether they happened in bullish or bearish months.
High/Low Occurrence Arrays
Four arrays (highBull, lowBull, highBear, lowBear) store the count of high and low occurrences for each day of the month. These arrays are the core of the statistical analysis.
Probability Calculation
Divides the count of occurrences for each day by the total number of months in that category (bullish/bearish). Multiplying by 100 converts this to a percentage probability, giving traders a numerical sense of recurrence.
Real-Time Updates
The table and probabilities are recalculated and refreshed with each new bar. This ensures that traders have the most current information available without manual recalculation.
User-Centric Visualization
By showing probabilities for both bullish and bearish months separately, traders gain a deeper understanding of market tendencies and recurring monthly patterns, which can be leveraged for improved timing and strategy alignment.
Important:
There is a misalign in percentages due to not all months having the same amount of days.
The indicator works by calculating in the following steps:
- Variable Declaration
Persistent variables (var) are used to store monthly highs, lows, open and close prices, and the days on which highs and lows occurred. Separate arrays track bullish and bearish month statistics for highs and lows (highBull, lowBull, highBear, lowBear). Counters (bullCount, bearCount) store the number of bullish and bearish months recorded. - New Month Detection
The script detects the start of a new month by comparing the current bar’s month to the previous bar’s month. If a new month is detected, the script proceeds to update statistics for the previous month. - Monthly High/Low Recording and Classification
At the start of each new month, the previous month’s high, low, open, and close are evaluated:
If monthClose > monthOpen, the month is classified as bullish.
If monthClose < monthOpen, the month is classified as bearish.
The arrays (highBull, lowBull, highBear, lowBear) are updated at the respective high and low days of the month by incrementing counts, which allows the script to keep track of the frequency of monthly highs and lows occurring on specific days. - Monthly High/Low Tracking
During the month, the script continuously updates monthHigh and monthLow if the current bar’s high exceeds monthHigh or the low is below monthLow. The days on which these highs and lows occur are recorded (highDay and lowDay). The monthClose variable is continuously updated to the latest closing price. - Probability Calculation
Once monthly data is accumulated, the script calculates probabilities for each day of the month:
bullHighProb and bullLowProb represent the probability (in percentage) that a bullish month’s high or low occurred on a given day.
bearHighProb and bearLowProb represent the probability for bearish months.
These probabilities are calculated by dividing the count of high or low occurrences on each day by the total number of bullish or bearish months, then multiplying by 100. This probabilistic approach allows traders to see recurring patterns for highs and lows across multiple months. - Gradient Coloring Function
The helper function gradientRelative computes a color gradient between lowColor and highColor based on the relative probability value. Higher probabilities are colored closer to highColor, and lower probabilities closer to lowColor. This visual representation allows for quick identification of the most probable days for highs and lows in bullish or bearish months. - Dynamic Updates
As new bars are processed, the table is updated in real-time with new probabilities reflecting the most recent month’s data. This dynamic behavior ensures that the table remains accurate and responsive to the latest market information.
Buy and Sell Conditions:
This indicator does not provide direct buy or sell signals. Instead, it provides probabilistic information about historical patterns for bullish and bearish months. Traders can use the table to:
Identify days in the month where highs or lows are statistically more likely to occur.
Combine with other trend-following or reversal strategies to optimize entry and exit points.
For example, if a trader notices that bullish month highs frequently occur around day 15, they may plan trades around that period when other indicators align.
Features and Parameters:
Dynamic Probability Table: Updates in real-time as new monthly data becomes available.
Historical Pattern Tracking: Maintains arrays for highs and lows in bullish and bearish months.
Gradient Visualization: Uses color interpolation to quickly highlight higher probability days.
Specifications:
Monthly High/Low Tracking
Tracks the highest and lowest prices within each month. This is the foundation of the probability calculations. It allows traders to understand when significant price events historically occur.
Bullish/Bearish Month Classification
Each month is classified based on the relationship between monthClose and monthOpen. This provides context for the high/low occurrences: whether they happened in bullish or bearish months.
High/Low Occurrence Arrays
Four arrays (highBull, lowBull, highBear, lowBear) store the count of high and low occurrences for each day of the month. These arrays are the core of the statistical analysis.
Probability Calculation
Divides the count of occurrences for each day by the total number of months in that category (bullish/bearish). Multiplying by 100 converts this to a percentage probability, giving traders a numerical sense of recurrence.
Real-Time Updates
The table and probabilities are recalculated and refreshed with each new bar. This ensures that traders have the most current information available without manual recalculation.
User-Centric Visualization
By showing probabilities for both bullish and bearish months separately, traders gain a deeper understanding of market tendencies and recurring monthly patterns, which can be leveraged for improved timing and strategy alignment.
Important:
There is a misalign in percentages due to not all months having the same amount of days.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。