OPEN-SOURCE SCRIPT
HorizonSigma Pro [CHE]

HorizonSigma Pro [CHE]
Disclaimer
Not every timeframe will yield good results. Very short charts are dominated by microstructure noise, spreads, and slippage; signals can flip and the tradable edge shrinks after costs. Very high timeframes adapt more slowly, provide fewer samples, and can lag regime shifts. When you change timeframe, you also change the ratios between horizon, lookbacks, and correlation windows—what works on M5 won’t automatically hold on H1 or D1. Liquidity, session effects (overnight gaps, news bursts), and volatility do not scale linearly with time. Always validate per symbol and timeframe, then retune horizon, z-length, correlation window, and either the neutral band or the z-threshold. On fast charts, “components” mode adapts quicker; on slower charts, “super” reduces noise. Keep prior-shift and calibration enabled, monitor Hit Rate with its confidence interval and the Brier score, and execute only on confirmed (closed-bar) values.
For example, what do “UP 61%” and “DOWN 21%” mean?
“UP 61%” is the model’s estimated probability that the close will be higher after your selected horizon—directional probability, not a price target or profit guarantee. “DOWN 21%” still reports the probability of up; here it’s 21%, which implies 79% for down (a short bias). The label switches to “DOWN” because the probability falls below your short threshold. With a neutral-band policy, for example ±7%, signals are: Long above 57%, Short below 43%, Neutral in between. In z-score mode, fixed z-cutoffs drive the call instead of percentages. The arrow length on the chart is an ATR-scaled projection to visualize reach; treat it as guidance, not a promise.
Part 1 — Scientific description
Objective.
The indicator estimates the probability that price will be higher after a user-defined horizon (a chosen number of bars) and emits long, short, or neutral decisions under explicit thresholds. It combines multi‑feature, z‑normalized inputs, adaptive correlation‑based weighting, a prior‑shifted sigmoid mapping, optional rolling probability calibration, and repaint‑safe confirmation. It also visualizes an ATR‑scaled forward projection and prints a compact statistics panel.
Data and labeling.
For each bar, the target label is whether price increased over the past chosen horizon. Learning is deliberately backward‑looking to avoid look‑ahead: features are associated with outcomes that are only known after that horizon has elapsed.
Feature engineering.
The feature set includes momentum, RSI, stochastic %K, MACD histogram slope, a normalized EMA(20/50) trend spread, ATR as a share of price, Bollinger Band width, and volume normalized by its moving average. All features are standardized over rolling windows. A compressed “super‑feature” is available that aggregates core trend and momentum components while penalizing excessive width (volatility). Users can switch between a “components” mode (weighted sum of individual features) and a “super” mode (single compressed driver).
Weighting and learning.
Weights are the rolling correlations between features (evaluated one horizon ago) and realized directional outcomes, smoothed by an EMA and optionally clamped to a bounded range to stabilize outliers. This produces an adaptive, regime‑aware weighting without explicit machine‑learning libraries.
Scoring and probability mapping.
The raw score is either the weighted component sum or the weighted super‑feature. The score is standardized again and passed through a sigmoid whose steepness is user‑controlled. A “prior shift” moves the sigmoid’s midpoint to the current base rate of up moves, estimated over the evaluation window, so that probabilities remain well‑calibrated when markets drift bullish or bearish. Probabilities and standardized scores are EMA‑smoothed for stability.
Decision policy.
Two modes are supported:
- Neutral band: go long if the probability is above one half plus a user‑set band; go short if it is below one half minus that band; otherwise stay neutral.
- Z‑score thresholds: use symmetric positive/negative cutoffs on the standardized score to trigger long/short.
Repaint protection.
All values used for decisions can be locked to confirmed (closed) bars. Intrabar updates are available as a preview, but confirmed values drive evaluation and stats.
Calibration.
An optional rolling linear calibration maps past confirmed probabilities to realized outcomes over the evaluation window. The mapping is clipped to the unit interval and can be injected back into the decision logic if desired. This improves reliability (probabilities that “mean what they say”) without necessarily improving raw separability.
Evaluation metrics.
The table reports: hit rate on signaled bars; a Wilson confidence interval for that hit rate at a chosen confidence level; Brier score as a measure of probability accuracy; counts of long/short trades; average realized return by side; profit factor; net return; and exposure (signal density). All are computed on rolling windows consistent with the learning scheme.
Visualization.
On the chart, an arrowed projection shows the predicted direction from the current bar to the chosen horizon, with magnitude scaled by ATR (optionally scaled by the square‑root of the horizon). Labels display either the decision probability or the standardized score. Neutral states can display a configurable icon for immediate recognition.
Computational properties.
The design relies on rolling means, standard deviations, correlations, and EMAs. Per‑bar cost is constant with respect to history length, and memory is constant per tracked series. Graphical objects are updated in place to obey platform limits.
Assumptions and limitations.
The method is correlation‑based and will adapt after regime changes, not before them. Calibration improves probability reliability but not necessarily ranking power. Intrabar previews are non‑binding and should not be evaluated as historical performance.
Part 2 — Trader‑facing description
What it does.
This tool tells you how likely price is to be higher after your chosen number of bars and converts that into Long / Short / Neutral calls. It learns, in real time, which components—momentum, trend, volatility, breadth, and volume—matter now, adjusts their weights, and shows you a probability line plus a forward arrow scaled by volatility.
How to set it up.
1) Choose your horizon. Intraday scalps: 5–10 bars. Swings: 10–30 bars. The default of 14 bars is a balanced starting point.
2) Pick a feature mode.
- components: granular and fast to adapt when leadership rotates between signals.
- super: cleaner single driver; less noise, slightly slower to react.
3) Decide how signals are triggered.
- Neutral band (probability based): intuitive and easy to tune. Widen the band for fewer, higher‑quality trades; tighten to catch more moves.
- Z‑score thresholds: consistent numeric cutoffs that ignore base‑rate drift.
4) Keep reliability helpers on. Leave prior shift and calibration enabled to stabilize probabilities across bullish/bearish regimes.
5) Smoothing. A short EMA on the probability or score reduces whipsaws while preserving turns.
6) Overlay. The arrow shows the call and a volatility‑scaled reach for the next horizon. Treat it as guidance, not a promise.
Reading the stats table.
- Hit Rate with a confidence interval: your recent accuracy with an uncertainty range; trust the range, not only the point.
- Brier Score: lower is better; it checks whether a stated “70%” really behaves like 70% over time.
- Profit Factor, Net Return, Exposure: quick triage of tradability and signal density.
- Average Return by Side: sanity‑check that the long and short calls each pull their weight.
Typical adjustments.
- Too many trades? Increase the neutral band or raise the z‑threshold.
- Missing the move? Tighten the band, or switch to components mode to react faster.
- Choppy timeframe? Lengthen the z‑score and correlation windows; keep calibration on.
- Volatility regime change? Revisit the ATR multiplier and enable square‑root scaling of horizon.
Execution and risk.
- Size positions by volatility (ATR‑based sizing works well).
- Enter on confirmed values; use intrabar previews only as early signals.
- Combine with your market structure (levels, liquidity zones). This model is statistical, not clairvoyant.
What it is not.
Not a black‑box machine‑learning model. It is transparent, correlation‑weighted technical analysis with strong attention to probability reliability and repaint safety.
Suggested defaults (robust starting point).
- Horizon 14; components mode; weight EMA 10; correlation window 500; z‑length 200.
- Neutral band around seven percentage points, or z‑threshold around one‑third of a standard deviation.
- Prior shift ON, Calibration ON, Use calibrated for decisions OFF to start.
- ATR multiplier 1.0; square‑root horizon scaling ON; EMA smoothing 3.
- Confidence setting equivalent to about 95%.
Disclaimer
No indicator guarantees profits. HorizonSigma Pro [CHE] is a decision aid; always combine with solid risk management and your own judgment. Backtest, forward test, and size responsibly.
The content provided, including all code and materials, is strictly for educational and informational purposes only. It is not intended as, and should not be interpreted as, financial advice, a recommendation to buy or sell any financial instrument, or an offer of any financial product or service. All strategies, tools, and examples discussed are provided for illustrative purposes to demonstrate coding techniques and the functionality of Pine Script within a trading context.
Any results from strategies or tools provided are hypothetical, and past performance is not indicative of future results. Trading and investing involve high risk, including the potential loss of principal, and may not be suitable for all individuals. Before making any trading decisions, please consult with a qualified financial professional to understand the risks involved.
By using this script, you acknowledge and agree that any trading decisions are made solely at your discretion and risk.
Enhance your trading precision and confidence 🚀
Best regards
Chervolino
Disclaimer
Not every timeframe will yield good results. Very short charts are dominated by microstructure noise, spreads, and slippage; signals can flip and the tradable edge shrinks after costs. Very high timeframes adapt more slowly, provide fewer samples, and can lag regime shifts. When you change timeframe, you also change the ratios between horizon, lookbacks, and correlation windows—what works on M5 won’t automatically hold on H1 or D1. Liquidity, session effects (overnight gaps, news bursts), and volatility do not scale linearly with time. Always validate per symbol and timeframe, then retune horizon, z-length, correlation window, and either the neutral band or the z-threshold. On fast charts, “components” mode adapts quicker; on slower charts, “super” reduces noise. Keep prior-shift and calibration enabled, monitor Hit Rate with its confidence interval and the Brier score, and execute only on confirmed (closed-bar) values.
For example, what do “UP 61%” and “DOWN 21%” mean?
“UP 61%” is the model’s estimated probability that the close will be higher after your selected horizon—directional probability, not a price target or profit guarantee. “DOWN 21%” still reports the probability of up; here it’s 21%, which implies 79% for down (a short bias). The label switches to “DOWN” because the probability falls below your short threshold. With a neutral-band policy, for example ±7%, signals are: Long above 57%, Short below 43%, Neutral in between. In z-score mode, fixed z-cutoffs drive the call instead of percentages. The arrow length on the chart is an ATR-scaled projection to visualize reach; treat it as guidance, not a promise.
Part 1 — Scientific description
Objective.
The indicator estimates the probability that price will be higher after a user-defined horizon (a chosen number of bars) and emits long, short, or neutral decisions under explicit thresholds. It combines multi‑feature, z‑normalized inputs, adaptive correlation‑based weighting, a prior‑shifted sigmoid mapping, optional rolling probability calibration, and repaint‑safe confirmation. It also visualizes an ATR‑scaled forward projection and prints a compact statistics panel.
Data and labeling.
For each bar, the target label is whether price increased over the past chosen horizon. Learning is deliberately backward‑looking to avoid look‑ahead: features are associated with outcomes that are only known after that horizon has elapsed.
Feature engineering.
The feature set includes momentum, RSI, stochastic %K, MACD histogram slope, a normalized EMA(20/50) trend spread, ATR as a share of price, Bollinger Band width, and volume normalized by its moving average. All features are standardized over rolling windows. A compressed “super‑feature” is available that aggregates core trend and momentum components while penalizing excessive width (volatility). Users can switch between a “components” mode (weighted sum of individual features) and a “super” mode (single compressed driver).
Weighting and learning.
Weights are the rolling correlations between features (evaluated one horizon ago) and realized directional outcomes, smoothed by an EMA and optionally clamped to a bounded range to stabilize outliers. This produces an adaptive, regime‑aware weighting without explicit machine‑learning libraries.
Scoring and probability mapping.
The raw score is either the weighted component sum or the weighted super‑feature. The score is standardized again and passed through a sigmoid whose steepness is user‑controlled. A “prior shift” moves the sigmoid’s midpoint to the current base rate of up moves, estimated over the evaluation window, so that probabilities remain well‑calibrated when markets drift bullish or bearish. Probabilities and standardized scores are EMA‑smoothed for stability.
Decision policy.
Two modes are supported:
- Neutral band: go long if the probability is above one half plus a user‑set band; go short if it is below one half minus that band; otherwise stay neutral.
- Z‑score thresholds: use symmetric positive/negative cutoffs on the standardized score to trigger long/short.
Repaint protection.
All values used for decisions can be locked to confirmed (closed) bars. Intrabar updates are available as a preview, but confirmed values drive evaluation and stats.
Calibration.
An optional rolling linear calibration maps past confirmed probabilities to realized outcomes over the evaluation window. The mapping is clipped to the unit interval and can be injected back into the decision logic if desired. This improves reliability (probabilities that “mean what they say”) without necessarily improving raw separability.
Evaluation metrics.
The table reports: hit rate on signaled bars; a Wilson confidence interval for that hit rate at a chosen confidence level; Brier score as a measure of probability accuracy; counts of long/short trades; average realized return by side; profit factor; net return; and exposure (signal density). All are computed on rolling windows consistent with the learning scheme.
Visualization.
On the chart, an arrowed projection shows the predicted direction from the current bar to the chosen horizon, with magnitude scaled by ATR (optionally scaled by the square‑root of the horizon). Labels display either the decision probability or the standardized score. Neutral states can display a configurable icon for immediate recognition.
Computational properties.
The design relies on rolling means, standard deviations, correlations, and EMAs. Per‑bar cost is constant with respect to history length, and memory is constant per tracked series. Graphical objects are updated in place to obey platform limits.
Assumptions and limitations.
The method is correlation‑based and will adapt after regime changes, not before them. Calibration improves probability reliability but not necessarily ranking power. Intrabar previews are non‑binding and should not be evaluated as historical performance.
Part 2 — Trader‑facing description
What it does.
This tool tells you how likely price is to be higher after your chosen number of bars and converts that into Long / Short / Neutral calls. It learns, in real time, which components—momentum, trend, volatility, breadth, and volume—matter now, adjusts their weights, and shows you a probability line plus a forward arrow scaled by volatility.
How to set it up.
1) Choose your horizon. Intraday scalps: 5–10 bars. Swings: 10–30 bars. The default of 14 bars is a balanced starting point.
2) Pick a feature mode.
- components: granular and fast to adapt when leadership rotates between signals.
- super: cleaner single driver; less noise, slightly slower to react.
3) Decide how signals are triggered.
- Neutral band (probability based): intuitive and easy to tune. Widen the band for fewer, higher‑quality trades; tighten to catch more moves.
- Z‑score thresholds: consistent numeric cutoffs that ignore base‑rate drift.
4) Keep reliability helpers on. Leave prior shift and calibration enabled to stabilize probabilities across bullish/bearish regimes.
5) Smoothing. A short EMA on the probability or score reduces whipsaws while preserving turns.
6) Overlay. The arrow shows the call and a volatility‑scaled reach for the next horizon. Treat it as guidance, not a promise.
Reading the stats table.
- Hit Rate with a confidence interval: your recent accuracy with an uncertainty range; trust the range, not only the point.
- Brier Score: lower is better; it checks whether a stated “70%” really behaves like 70% over time.
- Profit Factor, Net Return, Exposure: quick triage of tradability and signal density.
- Average Return by Side: sanity‑check that the long and short calls each pull their weight.
Typical adjustments.
- Too many trades? Increase the neutral band or raise the z‑threshold.
- Missing the move? Tighten the band, or switch to components mode to react faster.
- Choppy timeframe? Lengthen the z‑score and correlation windows; keep calibration on.
- Volatility regime change? Revisit the ATR multiplier and enable square‑root scaling of horizon.
Execution and risk.
- Size positions by volatility (ATR‑based sizing works well).
- Enter on confirmed values; use intrabar previews only as early signals.
- Combine with your market structure (levels, liquidity zones). This model is statistical, not clairvoyant.
What it is not.
Not a black‑box machine‑learning model. It is transparent, correlation‑weighted technical analysis with strong attention to probability reliability and repaint safety.
Suggested defaults (robust starting point).
- Horizon 14; components mode; weight EMA 10; correlation window 500; z‑length 200.
- Neutral band around seven percentage points, or z‑threshold around one‑third of a standard deviation.
- Prior shift ON, Calibration ON, Use calibrated for decisions OFF to start.
- ATR multiplier 1.0; square‑root horizon scaling ON; EMA smoothing 3.
- Confidence setting equivalent to about 95%.
Disclaimer
No indicator guarantees profits. HorizonSigma Pro [CHE] is a decision aid; always combine with solid risk management and your own judgment. Backtest, forward test, and size responsibly.
The content provided, including all code and materials, is strictly for educational and informational purposes only. It is not intended as, and should not be interpreted as, financial advice, a recommendation to buy or sell any financial instrument, or an offer of any financial product or service. All strategies, tools, and examples discussed are provided for illustrative purposes to demonstrate coding techniques and the functionality of Pine Script within a trading context.
Any results from strategies or tools provided are hypothetical, and past performance is not indicative of future results. Trading and investing involve high risk, including the potential loss of principal, and may not be suitable for all individuals. Before making any trading decisions, please consult with a qualified financial professional to understand the risks involved.
By using this script, you acknowledge and agree that any trading decisions are made solely at your discretion and risk.
Enhance your trading precision and confidence 🚀
Best regards
Chervolino
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
開源腳本
本著TradingView的真正精神,此腳本的創建者將其開源,以便交易者可以查看和驗證其功能。向作者致敬!雖然您可以免費使用它,但請記住,重新發佈程式碼必須遵守我們的網站規則。
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。