Breadth-Driven Swing StrategyWhat it does
This script trades the S&P 500 purely on market breadth extremes:
• Data source : INDEX:S5TH = % of S&P 500 stocks above their own 200-day SMA (range 0–100).
• Buy when breadth is washed-out.
• Sell when breadth is overheated.
It is long-only by design; shorting and ATR trailing stops have been removed to keep the logic minimal and transparent.
⸻
Signals in plain English
1. Long entry
A. A 200-EMA trough in breadth is printed and the trough value is ≤ 40 %.
or
B. A 5-EMA trough appears, its prominence passes the user threshold, and the lowest breadth reading in the last 20 bars is ≤ 20 %.
(Toggle this secondary trigger on/off with “ Enter also on 5-EMA trough ”.)
2. Exit (close long)
First 200-EMA peak whose breadth value is ≥ 70 %.
3. Risk control
A fixed stop-loss (% of entry price, default 8 %) is attached to every long trade.
⸻
Key parameters (defaults shown)
• Long EMA length 200 • Short EMA length 5
• Peak prominence 0.5 pct-pts • Trough prominence 3 pct-pts
• Peak level 70 % • Trough level 40 % • 5-EMA trough level 20 %
• Fixed stop-loss 8 %
• “Enter also on 5-EMA trough” = true (allows additional entries on extreme momentum reversals)
Feel free to tighten or relax any of these thresholds to match your risk profile or account for different market regimes.
⸻
How to use it
1. Load the script on a daily SPX / SPY chart.
(The price chart drives order execution; the breadth series is pulled internally and does not need to be on the chart.)
2. Verify the breadth feed.
INDEX:S5TH is updated after each session; your broker must provide it.
3. Back-test across several cycles.
Two decades of daily data is recommended to see how the rules behave in bear markets, range markets, and bull trends.
4. Adjust position sizing in the Properties tab.
The default is “100 % of equity”; change it if you prefer smaller allocations or pyramiding caps.
⸻
Why it can help
• Breadth signals often lead price, allowing entries before index-level momentum turns.
• Simple, rule-based exits prevent “waiting for confirmation” paralysis.
• Only one input series—easy to audit, no black-box math.
Trade-offs
• Relies on a single breadth metric; other internals (advance/decline, equal-weight returns, etc.) are ignored.
• May sit in cash during shallow pullbacks that never push breadth ≤ 40 %.
• Signals arrive at the end of the session (breadth is EoD data).
⸻
Disclaimer
This script is provided for educational purposes only and is not financial advice. Markets are risky; test thoroughly and use your own judgment before trading real money.
ストラテジー概要
本スクリプトは S&P500 のマーケットブレッド(内部需給) だけを手がかりに、指数をスイングトレードします。
• ブレッドデータ : INDEX:S5TH
(S&P500 採用銘柄のうち、それぞれの 200 日移動平均線を上回っている銘柄比率。0–100 %)
• 買い : ブレッドが極端に売られたタイミング。
• 売り : ブレッドが過熱状態に達したタイミング。
余計な機能を削り、ロングオンリー & 固定ストップ のシンプル設計にしています。
⸻
シグナルの流れ
1. ロングエントリー
• 条件 A : 200-EMA がトラフを付け、その値が 40 % 以下
• 条件 B : 5-EMA がトラフを付け、
・プロミネンス条件を満たし
・直近 20 本のブレッドス最小値が 20 % 以下
• B 条件は「5-EMA トラフでもエントリー」を ON にすると有効
2. ロング決済
最初に出現した 200-EMA ピーク で、かつ値が 70 % 以上 のバーで手仕舞い。
3. リスク管理
各トレードに 固定ストップ(初期価格から 8 %)を設定。
⸻
主なパラメータ(デフォルト値)
• 長期 EMA 長さ : 200 • 短期 EMA 長さ : 5
• ピーク判定プロミネンス : 0.5 %pt • トラフ判定プロミネンス : 3 %pt
• ピーク水準 : 70 % • トラフ水準 : 40 % • 5-EMA トラフ水準 : 20 %
• 固定ストップ : 8 %
• 「5-EMA トラフでもエントリー」 : ON
相場環境やリスク許容度に合わせて閾値を調整してください。
⸻
使い方
1. 日足の SPX / SPY チャート にスクリプトを適用。
2. ブレッドデータの供給 (INDEX:S5TH) がブローカーで利用可能か確認。
3. 20 年以上の期間でバックテスト し、強気相場・弱気相場・レンジ局面での挙動を確認。
4. 資金配分 は プロパティ → 戦略実行 で調整可能(初期値は「資金の 100 %」)。
⸻
強み
• ブレッドは 価格より先行 することが多く、天底を早期に捉えやすい。
• ルールベースの出口で「もう少し待とう」と迷わずに済む。
• 入力 series は 1 本のみ、ブラックボックス要素なし。
注意点・弱み
• 単一指標に依存。他の内部需給(A/D ライン等)は考慮しない。
• 40 % を割らない浅い押し目では機会損失が起こる。
• ブレッドは終値ベースの更新。ザラ場中の変化は捉えられない。
⸻
免責事項
本スクリプトは 学習目的 で提供しています。投資助言ではありません。
実取引の前に必ず自己責任で十分な検証とリスク管理を行ってください。
指标和策略
BTST By ANTThe BTST Indicator is a powerful tool specifically designed for traders in the Indian stock market. This unique indicator identifies and highlights key price movements at a pivotal time—3:15 PM. This time is crucial for making BTST (Buy Today, Sell Tomorrow) decisions, a popular trading strategy in India.
Key Features:
Gap Identification : The indicator detects whether the current price action represents a gap-up or gap-down situation compared to the Heikinashi candle close price. This information is vital for short-term traders looking to capitalize on price momentum.
Visual Alerts : When a gap-up trend is detected, a green label "Gap Up" is displayed above the relevant bar. Similarly, a red label "Gap Down" appears below the bar for gap-down movements. These visual indicators help traders make quick and informed decisions.
User-Friendly Insights: The BTST Indicator provides vital information about last closed prices and the dynamics between normal candles and Heikinashi candles. With detailed logs, users can see the exact conditions leading to buy or sell signals, helping optimize trading strategies.
Why Use the BTST Indicator?
Timeliness: The focus on the 3:15 PM mark aligns perfectly with trading patterns and market behavior specific to the Indian stock market, making it an invaluable addition to your trading arsenal.
Enhanced Decision-Making: By receiving immediate visual cues on significant price movements, traders can execute their BTST strategies with greater confidence and speed.
Designed for Indian Markets: This indicator caters specifically to the nuances of Indian stock trading, ensuring relevance and effectiveness for local traders.
Start utilizing the BTST Indicator today to enhance your trading strategies and position yourself for successful trades in the Indian stock market!
Global M2 [BizFing]MARKETSCOM:BITCOIN ECONOMICS:USM2
This is an indicator designed to show the correlation between the global M2 money supply and Bitcoin.
This indicator basically provides a Global M2 index by summing the M2 money supply data from the United States, South Korea, China, Japan, the EU, and the United Kingdom.
Furthermore, it is configured to allow you to add or remove the M2 data of desired countries within the settings.
I hope this proves to be a small aid in predicting the future price of Bitcoin.
If you have any questions or require any improvements while using it, please feel free to contact me.
Thank you.
Pmax + T3Pmax + T3 is a versatile hybrid trend-momentum indicator that overlays two complementary systems on your price chart:
1. Pmax (EMA & ATR “Risk” Zones)
Calculates two exponential moving averages (Fast EMA & Slow EMA) and plots them to gauge trend direction.
Highlights “risk zones” behind price as a colored background:
Green when Fast EMA > Slow EMA (up-trend)
Red when Fast EMA < Slow EMA (down-trend)
Yellow when EMAs are close (“flat” zone), helping you avoid choppy markets.
You can toggle risk-zone highlighting on/off, plus choose to ignore signals in the yellow (neutral) zone.
2. T3 (Triple-Smoothed EMA Momentum)
Applies three sequential EMA smoothing (the classic “T3” algorithm) to your chosen source (usually close).
Fills the area between successive T3 curves with up/down colors for a clear visual of momentum shifts.
Optional neon-glow styling (outer, mid, inner glows) in customizable widths and transparencies for a striking “cyber” look.
You can highlight T3 movements only when the line is rising (green) or falling (red), or disable movement coloring.
Moving Average ToolkitMoving Average Toolkit - Advanced MA Analysis with Flexible Source Input
A powerful and versatile moving average indicator designed for maximum flexibility. Its unique source input feature allows you to analyze moving averages of ANY indicator or price data, making it perfect for creating custom combinations with RSI, Volume, OBV, or any other technical indicator.
Key Features:
• Universal Source Input:
- Analyze moving averages of any data: Price, Volume, RSI, MACD, Custom Indicators
- Perfect for creating advanced technical setups
- Identify trends in any technical data
• 13 Moving Average Types:
- Traditional: SMA, EMA, WMA, RMA, VWMA
- Advanced: HMA, T3, DEMA, TEMA, KAMA, ZLEMA, McGinley, EPMA
• Dual MA System:
- Compare two different moving averages
- Independent settings for each MA
- Perfect for multiple timeframe analysis
• Visual Offset Analysis:
- Dynamic color changes based on momentum
- Fill between current and offset values
- Clear visualization of trend strength
Usage Examples:
• Price Trend: Traditional MA analysis using price data
• Volume Trend: Apply MA to volume for volume trend analysis
• RSI Trend: Smooth RSI movements for clearer signals
• Custom: Apply to any indicator output for unique insights
Settings:
• Fully customizable colors for bull/bear conditions
• Adjustable offset periods
• Independent length settings
• Optional second MA for comparison
Perfect for:
• Advanced technical analysts
• Multi-indicator strategy developers
• Custom indicator creators
• Traders seeking flexible analysis tools
This versatile toolkit goes beyond traditional moving averages by allowing you to apply sophisticated MA analysis to any technical data, creating endless possibilities for custom technical analysis strategies.
CISD [TakingProphets]🧠 Indicator Purpose:
The "CISD - Change in State of Delivery" is a precision tool designed for traders utilizing ICT (Inner Circle Trader) conecpets. It detects critical shifts in delivery conditions after liquidity sweeps — helping you spot true smart money activity and optimal trade opportunities. This script is especially valuable for traders applying liquidity concepts, displacement recognition, and market structure shifts at both intraday and swing levels.
🌟 What Makes This Indicator Unique:
Unlike basic trend-following or scalping tools, CISD operates through a two-phase smart money logic:
Liquidity Sweep Detection (sweeping Buyside or Sellside Liquidity).
State of Delivery Change Identification (through bearish or bullish displacement after the sweep).
It intelligently tracks candle sequences and only signals a CISD event after true displacement — offering a much deeper context than ordinary indicators.
⚙️ How the Indicator Works:
Swing Point Detection: Identifies recent pivot highs/lows to map Buyside Liquidity (BSL) and Sellside Liquidity (SSL) zones.
Liquidity Sweeps: Watches for price breaches of these liquidity points to detect institutional stop hunts.
Sequence Recognition: Finds series of same-direction candles before sweeps to mark institutional accumulation/distribution.
Change of Delivery Confirmation: Confirms CISD only after significant displacement moves price against the initial candle sequence.
Visual Markings: Automatically plots CISD lines and optional labels, customizable in color, style, and size.
🎯 How to Use It:
Identify Liquidity Sweeps: Watch for CISD levels plotted after a liquidity sweep event.
Plan Entries: Look for retracements into CISD lines for high-probability entries.
Manage Risk: Use CISD levels to refine your stop-loss and profit-taking zones.
Best Application:
After stop hunts during Killzones (London Open, New York AM).
As part of the Flow State Model: identify higher timeframe PD Arrays ➔ wait for lower timeframe CISD confirmation.
🔎 Underlying Concepts:
Liquidity Pools: Highs and lows cluster stop orders, attracting institutional sweeps.
Displacement: Powerful price moves post-sweep confirm smart money involvement.
Market Structure: CISD frequently precedes major Change of Character (CHoCH) or Break of Structure (BOS) shifts.
🎨 Customization Options:
Adjustable line color, width, and style (solid, dashed, dotted).
Optional label display with customizable color and sizing.
Line extension settings to keep CISD zones visible for future reference.
✅ Recommended for:
Traders studying ICT Smart Money Concepts.
Intraday scalpers and higher timeframe swing traders.
Traders who want to improve entries around liquidity sweeps and institutional displacement moves.
🚀 Bonus Tip:
For maximum confluence, pair this with the HTF POI, ICT Liquidity Levels, and HTF Market Structure indicators available at TakingProphets.com! 🔥
BTC Price-Volume Efficiency Z-Score (PVER-Z)Overview:
This PVER-Z Score measures Bitcoin’s price movement efficiency relative to trading volume, normalized using a Z-Score over a long-term 200-day period.
It highlights statistically rare inefficiencies, helping investors spot extreme accumulation and distribution zones for systematic SDCA strategies.
Concept:
- Measures how efficiently price has moved relative to the volume that supported it over a long historical window (Default 200 days) but can be adjustable.
- It compares cumulative price changes vs cumulative volume flow.
- Then normalizes those inefficiencies using Z-Score statistics.
How It Works:
1. Calculates the absolute daily price change divided by volume (price-volume efficiency ratio).
2. Applies EMA smoothing to remove noisy fluctuations.
3. Normalizes the result into a Z-Score to detect statistically significant outliers.
4. Plots dynamic heatmap colors as the efficiency score moves through different deviation zones.
5. Background fills appear when the Z-Score moves beyond ±2 to ±3 SD, signaling rare macro opportunities.
Why is Bitcoin price rising while PVER-Z is falling toward green zone?
1. PVER-Z is not just "price" — it's price change relative to volume. PVER-Z measures how efficient the price movement is relative to volume. It's not "price going up" or "price going down" directly. It's how unusual or inefficient the price versus volume relationship is, compared to its historical average.
2. A rising Bitcoin price + weak efficiency = PVER-Z falls.
If Bitcoin rises but volume is super strong (normal buying volume), no problem, the PVER-Z stays normal. If Bitcoin rises but with very weak volume support, PVER-Z falls.
***Usage Notes***:
- Best used on the daily timeframe or higher.
- When the Z-Score enters the green zone (-2 to -3 SD), it signals a historically rare accumulation zone — favoring long-term buying for SDCA.
- When the Z-Score enters the red zone (+2 to +3 SD), it signals overextended distribution — caution recommended.
- Designed strictly for mean-reversion analysis, no trend-following signals.
- The red zone on a proper Z chart would be -2SD to -3SD and +2SD to +3SD for the green zone. At the time of publishing I do not know how to adjust the values on the indicator itself. The red zone at -2SD is actually +2 Standard Deviations on a Z Score SD Chart. (overbought zone).
- Your green zone at +2SD is actually -2SD Standard Deviations (oversold zone).
- Built manually with no reliance on built-in indicators
- Designed for Bitcoin on the 1D, 3D, or Weekly timeframes. NOT for intraday trading.
- DO NOT SOELY RELY ON THIS INDICATOR FOR YOUR LONG TERM VALUATION. I AM NOT RESPONSIBLE FOR YOUR FINANICAL ASSETS.
TUF_LOGICTUF_LOGIC: Three-Value Logic for Pine Script v6
The TUF_LOGIC library implements a robust three-valued logic system (trilean logic) for Pine Script v6, providing a formal framework for reasoning about uncertain or incomplete information in financial markets. By extending beyond binary True/False states to include an explicit "Uncertain" state, this library enables more nuanced algorithmic decision-making, particularly valuable in environments characterized by imperfect information.
Core Architecture
TUF_LOGIC offers two complementary interfaces for working with trilean values:
Enum-Based API (Recommended): Leverages Pine Script v6's enum capabilities with Trilean.True , Trilean.Uncertain , and Trilean.False for improved type safety and performance.
Integer-Based API (Legacy Support): Maintains compatibility with existing code using integer values 1 (True), 0 (Uncertain), and -1 (False).
Fundamental Operations
The library provides type conversion methods for seamless interaction between integer representation and enum types ( to_trilean() , to_int() ), along with validation functions to maintain trilean invariants.
Logical Operators
TUF_LOGIC extends traditional boolean operators to the trilean domain with NOT , AND , OR , XOR , and EQUALITY functions that properly handle the Uncertain state according to the principles of three-valued logic.
The library implements three different implication operators providing flexibility for different logical requirements: IMP_K (Kleene's approach), IMP_L (Łukasiewicz's approach), and IMP_RM3 (Relevant implication under RM3 logic).
Inspired by Tarski-Łukasiewicz's modal logic formulations, TUF_LOGIC includes modal operators: MA (Modal Assertion) evaluates whether a state is possibly true; LA (Logical Assertion) determines if a state is necessarily true; and IA (Indeterminacy Assertion) identifies explicitly uncertain states.
The UNANIMOUS operator evaluates trilean values for complete agreement, returning the consensus value if one exists or Uncertain otherwise. This function is available for both pairs of values and arrays of trilean values.
Practical Applications
TUF_LOGIC excels in financial market scenarios where decision-making must account for uncertainty. It enables technical indicator consensus by combining signals with different confidence levels, supports multi-timeframe analysis by reconciling potentially contradictory signals, enhances risk management by explicitly modeling uncertainty, and handles partial information systems where some data sources may be unreliable.
By providing a mathematically sound framework for reasoning about uncertainty, TUF_LOGIC elevates trading system design beyond simplistic binary logic, allowing for more sophisticated decision-making that better reflects real-world market complexity.
Library "TUF_LOGIC"
Three-Value Logic (TUF: True, Uncertain, False) implementation for Pine Script.
This library provides a comprehensive set of logical operations supporting trilean logic systems,
including Kleene, Łukasiewicz, and RM3 implications. Compatible with Pine v6 enums.
method validate(self)
Ensures a valid trilean integer value by clamping to the appropriate range .
Namespace types: series int, simple int, input int, const int
Parameters:
self (int) : The integer value to validate.
Returns: An integer value guaranteed to be within the valid trilean range.
method to_trilean(self)
Converts an integer value to a Trilean enum value.
Namespace types: series int, simple int, input int, const int
Parameters:
self (int) : The integer to convert (typically -1, 0, or 1).
Returns: A Trilean enum value: True (1), Uncertain (0), or False (-1).
method to_int(self)
Converts a Trilean enum value to its corresponding integer representation.
Namespace types: series Trilean
Parameters:
self (series Trilean) : The Trilean enum value to convert.
Returns: Integer value: 1 (True), 0 (Uncertain), or -1 (False).
method NOT(self)
Negates a trilean integer value (NOT operation).
Namespace types: series int, simple int, input int, const int
Parameters:
self (int) : The integer value to negate.
Returns: Negated integer value: 1 -> -1, 0 -> 0, -1 -> 1.
method NOT(self)
Negates a Trilean enum value (NOT operation).
Namespace types: series Trilean
Parameters:
self (series Trilean) : The Trilean enum value to negate.
Returns: Negated Trilean: True -> False, Uncertain -> Uncertain, False -> True.
method AND(self, comparator)
Logical AND operation for trilean integer values.
Namespace types: series int, simple int, input int, const int
Parameters:
self (int) : The first integer value.
comparator (int) : The second integer value to compare with.
Returns: Integer result of the AND operation (minimum value).
method AND(self, comparator)
Logical AND operation for Trilean enum values following three-valued logic.
Namespace types: series Trilean
Parameters:
self (series Trilean) : The first Trilean enum value.
comparator (series Trilean) : The second Trilean enum value to compare with.
Returns: Trilean result of the AND operation.
method OR(self, comparator)
Logical OR operation for trilean integer values.
Namespace types: series int, simple int, input int, const int
Parameters:
self (int) : The first integer value.
comparator (int) : The second integer value to compare with.
Returns: Integer result of the OR operation (maximum value).
method OR(self, comparator)
Logical OR operation for Trilean enum values following three-valued logic.
Namespace types: series Trilean
Parameters:
self (series Trilean) : The first Trilean enum value.
comparator (series Trilean) : The second Trilean enum value to compare with.
Returns: Trilean result of the OR operation.
method EQUALITY(self, comparator)
Logical EQUALITY operation for trilean integer values.
Namespace types: series int, simple int, input int, const int
Parameters:
self (int) : The first integer value.
comparator (int) : The second integer value to compare with.
Returns: Integer representation (1/-1) indicating if values are equal.
method EQUALITY(self, comparator)
Logical EQUALITY operation for Trilean enum values.
Namespace types: series Trilean
Parameters:
self (series Trilean) : The first Trilean enum value.
comparator (series Trilean) : The second Trilean enum value to compare with.
Returns: Trilean.True if both values are equal, Trilean.False otherwise.
method XOR(self, comparator)
Logical XOR (Exclusive OR) operation for trilean integer values.
Namespace types: series int, simple int, input int, const int
Parameters:
self (int) : The first integer value.
comparator (int) : The second integer value to compare with.
Returns: Integer result of the XOR operation.
method XOR(self, comparator)
Logical XOR (Exclusive OR) operation for Trilean enum values.
Namespace types: series Trilean
Parameters:
self (series Trilean) : The first Trilean enum value.
comparator (series Trilean) : The second Trilean enum value to compare with.
Returns: Trilean result of the XOR operation.
method IMP_K(self, comparator)
Material implication using Kleene's logic for trilean integer values.
Namespace types: series int, simple int, input int, const int
Parameters:
self (int) : The antecedent integer value.
comparator (int) : The consequent integer value.
Returns: Integer result of Kleene's implication operation.
method IMP_K(self, comparator)
Material implication using Kleene's logic for Trilean enum values.
Namespace types: series Trilean
Parameters:
self (series Trilean) : The antecedent Trilean enum value.
comparator (series Trilean) : The consequent Trilean enum value.
Returns: Trilean result of Kleene's implication operation.
method IMP_L(self, comparator)
Logical implication using Łukasiewicz's logic for trilean integer values.
Namespace types: series int, simple int, input int, const int
Parameters:
self (int) : The antecedent integer value.
comparator (int) : The consequent integer value.
Returns: Integer result of Łukasiewicz's implication operation.
method IMP_L(self, comparator)
Logical implication using Łukasiewicz's logic for Trilean enum values.
Namespace types: series Trilean
Parameters:
self (series Trilean) : The antecedent Trilean enum value.
comparator (series Trilean) : The consequent Trilean enum value.
Returns: Trilean result of Łukasiewicz's implication operation.
method IMP_RM3(self, comparator)
Logical implication using RM3 logic for trilean integer values.
Namespace types: series int, simple int, input int, const int
Parameters:
self (int) : The antecedent integer value.
comparator (int) : The consequent integer value.
Returns: Integer result of the RM3 implication operation.
method IMP_RM3(self, comparator)
Logical implication using RM3 logic for Trilean enum values.
Namespace types: series Trilean
Parameters:
self (series Trilean) : The antecedent Trilean enum value.
comparator (series Trilean) : The consequent Trilean enum value.
Returns: Trilean result of the RM3 implication operation.
method MA(self)
Modal Assertion (MA) operation for trilean integer values.
Namespace types: series int, simple int, input int, const int
Parameters:
self (int) : The integer value to evaluate.
Returns: 1 if the value is 1 or 0, -1 if the value is -1.
method MA(self)
Modal Assertion (MA) operation for Trilean enum values.
Namespace types: series Trilean
Parameters:
self (series Trilean) : The Trilean enum value to evaluate.
Returns: Trilean.True if value is True or Uncertain, Trilean.False if value is False.
method LA(self)
Logical Assertion (LA) operation for trilean integer values.
Namespace types: series int, simple int, input int, const int
Parameters:
self (int) : The integer value to evaluate.
Returns: 1 if the value is 1, -1 otherwise.
method LA(self)
Logical Assertion (LA) operation for Trilean enum values.
Namespace types: series Trilean
Parameters:
self (series Trilean) : The Trilean enum value to evaluate.
Returns: Trilean.True if value is True, Trilean.False otherwise.
method IA(self)
Indeterminacy Assertion (IA) operation for trilean integer values.
Namespace types: series int, simple int, input int, const int
Parameters:
self (int) : The integer value to evaluate.
Returns: 1 if the value is 0, -1 otherwise.
method IA(self)
Indeterminacy Assertion (IA) operation for Trilean enum values.
Namespace types: series Trilean
Parameters:
self (series Trilean) : The Trilean enum value to evaluate.
Returns: Trilean.True if value is Uncertain, Trilean.False otherwise.
method UNANIMOUS(self, comparator)
Evaluates the unanimity between two trilean integer values.
Namespace types: series int, simple int, input int, const int
Parameters:
self (int) : The first integer value.
comparator (int) : The second integer value.
Returns: Integer value of self if both values are equal, 0 (Uncertain) otherwise.
method UNANIMOUS(self, comparator)
Evaluates the unanimity between two Trilean enum values.
Namespace types: series Trilean
Parameters:
self (series Trilean) : The first Trilean enum value.
comparator (series Trilean) : The second Trilean enum value.
Returns: Value of self if both values are equal, Trilean.Uncertain otherwise.
method UNANIMOUS(self)
Evaluates the unanimity among an array of trilean integer values.
Namespace types: array
Parameters:
self (array) : The array of integer values.
Returns: First value if all values are identical, 0 (Uncertain) otherwise.
method UNANIMOUS(self)
Evaluates the unanimity among an array of Trilean enum values.
Namespace types: array
Parameters:
self (array) : The array of Trilean enum values.
Returns: First value if all values are identical, Trilean.Uncertain otherwise.
Gabriel's Adaptive MA📜 Gabriel's Adaptive MA — Indicator Description
Gabriel's Adaptive Moving Average (GAMA) is a dynamic trend-following indicator that intelligently adjusts its smoothing based on both trend strength and market volatility.
It is designed to provide faster responsiveness during strong moves while maintaining stability during choppy or consolidating periods.
🧠 What it does:
This indicator plots a custom-built, highly dynamic Moving Average that adapts itself intelligently based on:
Trend Strength (via Perry Kaufman's Efficiency Ratio)
Market Volatility (via Tushar Chande's Volatility Ratio)
It reacts faster when the market is trending strongly and/or highly volatile,
and it smooths out and slows down when the market is choppy or calm.
🔍 How it works (step-by-step):
1. User Inputs:
length: (default 14)
How many bars to look back for calculations.
fastSC: Fastest possible smoothing constant (hardcoded as 2 / (2+1))
slowSC: Slowest possible smoothing constant (hardcoded as 2 / (30+1))
(These are used to control how fast/slow the KAMA can react.)
2. Calculate Trendiness — Kaufman Efficiency Ratio (ER):
Net Change = Absolute difference between current close and close from length bars ago.
Sum of Absolute Changes = Sum of absolute price changes between every bar inside the length window.
Efficiency Ratio (ER) = Net Change divided by Sum of Changes.
✅ If ER is close to 1 → Smooth, trending market.
✅ If ER is close to 0 → Choppy, sideways market.
3. Calculate Bumpiness — Volatility Ratio (VR):
Short-Term Volatility = Standard deviation of close over length.
Long-Term Volatility = Standard deviation of close over length * 2.
Volatility Ratio (VR) = Short-Term Volatility divided by Long-Term Volatility.
✅ If VR is >1 → Market is becoming more volatile recently.
✅ If VR is <1 → Market is calming down.
4. Create the Hybrid Alpha:
Multiply ER × VR.
Then square the result (math.pow(..., 2)).
This hybrid alpha decides how aggressive the MA should be based on both trend and volatility.
If ER and VR are both strong → big alpha → fast movement.
If ER and/or VR are weak → small alpha → slow movement.
5. Calculate the Final Adaptive Smoothing Constant (hybridSC):
hybridSC = slowSC + hybridAlpha × (fastSC - slowSC)
This smoothly interpolates between the slowest and fastest smoothing depending on market conditions.
6. Calculate and Plot the Adaptive MA:
The moving average is manually calculated:
hybridMA := na(hybridMA ) ? close : hybridMA + hybridSC * (close - hybridMA )
It behaves like an EMA but with dynamic smoothing, not a fixed alpha.
✅ If hybridSC is high → MA hugs the price closely.
✅ If hybridSC is low → MA stays smooth and resists noise.
Finally, it plots this Adaptive MA on the chart in blue color.
📊 Visual Summary
Market Type What Happens to GAMA
Trending hard + volatile Follows price quickly
Trending hard + calm Follows steadily but carefully
Sideways + volatile Reacts carefully (won't chase noise)
Sideways + calm Smooths heavily (avoids fakeouts)
✨ Main Strengths:
Adapts automatically without you tuning settings manually every time market changes.
Responds smartly to both trend quality (ER) and market energy (VR).
Reduces lag during real moves.
Filters out false signals during choppy mess.
🧪 Key Innovation compared to normal MAs:
Traditional MA Gabriel's Adaptive MA
Same smoothing every bar Dynamic smoothing every bar
Slow during fast moves Adapts fast during real moves
No understanding of volatility or trendiness Full market sensitivity
⚡ **Simple One-Line Description:**
"Gabriel's Adaptive MA is a dynamic, trend-and-volatility-sensitive moving average that intelligently adjusts its speed to match market conditions."
Market Breadth Peaks & Troughs IndicatorIndicator Overview
Market Breadth (S5TH) visualizes extremes of market strength and weakness by overlaying -
a 200-period EMA (long-term trend)
a 5-period EMA (short-term trend, user-adjustable)
on the percentage of S&P 500 constituents trading above their 200-day SMA (INDEX:S5TH).
Peaks (▼) and troughs (▲) are detected with prominence filters so you can quickly spot overbought and oversold conditions.
⸻
1. Core Logic
Component Description
Breadth series INDEX:S5TH — % of S&P 500 stocks above their 200-SMA
Long EMA 200-EMA to capture the primary trend
Short EMA 5-EMA (default, editable) for short-term swings
Peak detection ta.pivothigh + prominence ⇒ major peaks marked with red ▼
Trough detection (200 EMA) ta.pivotlow + prominence + value < longTroughLvl ⇒ blue ▲
Trough detection (5 EMA) ta.pivotlow + prominence + value < shortTroughLvl ⇒ green ▲
Background shading Pink when 200 EMA slope is down and 5 EMA sits below 200 EMA
⸻
2. Adjustable Parameters (input())
Group Variable Default Purpose
Symbol breadthSym INDEX:S5TH Breadth index
Long EMA longLen 200 Period of long EMA
Short EMA shortLen 5 Period of short EMA
Pivot width (long) pivotLen 20 Bars left/right for 200-EMA peaks/troughs
Pivot width (short) pivotLenS 10 Bars for 5-EMA troughs
Prominence (long) promThresh 0.5 %-pt Depth filter for 200-EMA pivots
Prominence (short) promThreshS 3.0 %-pt Depth filter for 5-EMA pivots
Trough level (long) longTroughLvl 50 % Max value to accept a 200-EMA trough
Trough level (short) shortTroughLvl 30 % Max value to accept a 5-EMA trough
⸻
3. Signal Guide
Marker / Color Meaning Typical reading
Red ▼ Major breadth peak Overbought / possible top
Blue ▲ Deep 200-EMA trough End of mid-term correction
Green ▲ Shallow 5-EMA trough (early) Short-term rebound setup
Pink background Long-term down-trend and short-term weak Risk-off phase
⸻
4. Typical Use Cases
1. Counter-trend timing
• Fade greed: trim longs on red ▼
• Buy fear: scale in on green ▲; add on blue ▲
2. Trend filter
• Avoid new longs while the background is pink; wait for a trough & recovery.
3. Risk management
• Reduce exposure when peaks appear, reload partial size on confirmed troughs.
⸻
5. Notes & Tips
• INDEX:S5TH is sourced from TradingView and may be back-adjusted when index membership changes.
• Fine-tune pivotLen, promThresh, and level thresholds to match current volatility before relying on alerts or automated rules.
• Slope thresholds (±0.10 %-pt) that trigger background shading can also be customized for different market regimes.
RSI + MACD + Liquidity FinderLiquidity Finder: The liquidity zones are heuristic and based on volume and swing points. You may need to tweak the volumeThreshold and lookback to match the asset's volatility and timeframe.
Timeframe: This script works on any timeframe, but signals may vary in reliability (e.g., higher timeframes like 4H or 1D may reduce noise).
Customization: You can modify signal conditions (e.g., require only RSI or MACD) or add filters like trend direction using moving averages.
Backtesting: Use TradingView's strategy tester to evaluate performance by converting the indicator to a strategy (replace plotshape with strategy.entry/strategy.close).
Accurate Global M2 (Top10 GDP, FX-Stabilized)This script was created to solve the serious distortions found in other circulating "Global M2" indicators.
Many previous versions used noisy daily FX rates, unweighted country data, mixed liquidity categories (e.g., RRP, TGA), or aggregated low-quality sources, causing exaggerated or misleading charts.
This version fixes those problems by:
Using Top 10 global economies only (based on GDP).
GDP-weighting each country's M2 contribution.
Fetching monthly-averaged M2 data.
Applying monthly FX conversions to eliminate daily volatility noise.
Forward-shifting the M2 line (default 90 days) to study potential Bitcoin correlations.
Keeping the math clean, without mixing central bank liquidity tools with broad M2 aggregates.
As a result, this script provides a more realistic and stable representation of global M2 expansion in USD terms, more suitable for serious macroeconomic analysis and Bitcoin market correlation studies.
Kalman Filtered RSI | [DeV]The Kalman Filtered RSI indicator is an advanced tool designed for traders who want precise, noise-free market insights. By enhancing the classic Relative Strength Index (RSI) with a Kalman filter, this indicator delivers a smoother, more reliable view of market momentum, helping you identify trends, reversals, and overbought/oversold conditions with greater accuracy. It’s an ideal choice for traders seeking clear signals amidst market volatility, giving you a competitive edge across any trading environment.
The RSI measures momentum by analyzing price movements over a set period, typically 14 bars. It calculates the average of price gains on up days and the average of price losses on down days, then compares these to produce a value between 0 and 100. An RSI above 70 often indicates an overbought market that may reverse downward, while below 30 suggests an oversold market that could reverse upward. RSI is great for spotting momentum shifts, potential reversals, and trend strength, but it can be noisy in choppy markets, leading to misleading signals.
That's where the Kalman filter comes in; it enhances the RSI by applying a sophisticated smoothing process that predicts the RSI’s next value based on its historical trend, then updates this prediction with the actual RSI reading. It operates in two phases: prediction and correction. In the prediction phase, it uses the previous filtered RSI and adds uncertainty from process noise (Q), which is derived from the historical variance of RSI changes, reflecting how much the RSI might unexpectedly shift. In the correction phase, it calculates a Kalman gain based on the ratio of prediction uncertainty to measurement noise (R), which is determined from the variance between raw RSI and a smoothed version, indicating the raw data’s noisiness. This gain weights how much the filter trusts the new RSI versus the prediction, blending them to produce a smoothed RSI that reduces noise while staying responsive to real trends, outperforming simpler methods like moving averages that often lag or oversmooth.
With the Kalman Filtered RSI, you get a refined view of momentum, making it easier to spot trends and reversals with clarity. This indicator’s ability to dynamically adapt to market changes delivers timely, reliable signals, making it a powerful addition to your trading strategy for any market or timeframe.
Anchored Bollinger Band Range [SS]This is the anchored Bollinger band indicator.
What it does?
The anchored BB indicator:
Takes a user defined range and calculates the Standard Deviation of the entire selected range for the high and low values.
Computes a moving average of the high and low during the selected period (which later becomes the breakout range average)
Anchors to the last high and last low of the period range to add up to 4 standard deviations to the upside and downside, giving you 4 high and low targets.
How can you use it?
The anchored BB indicator has many applicable uses, including
Identifying daily ranges based on premarket trading activity ( see below ):
Finding breakout ranges for intraday pattern setups ( see below ):
Identified pattern of interest:
Applying Anchored BB:
Identifying daily or pattern biases based on the position to the opening breakout range average (blue line). See the examples with explanations:
ex#1:
ex#2:
The Opening Breakout Average
As you saw in the examples above, the blue line represents the opening breakout range average.
This is the average high of the period of interest and the average low of the period of interest.
Price action above this line would be considered Bullish, and Bearish if below.
This also acts as a retracement zone in non-trending markets. For example:
Best Use Cases
Identify breakout ranges for patterns on larger timeframes. For example
This pattern on SPY, if we overlay the Anchored BB:
You want to see it actually breakout from this range and hold to confirm a breakout. Failure to exceed the BB range, means that it is just ranging with no real breakout momentum.
Identify conservative ranges for a specific period in time, for example QQQ:
Worst Use Cases
Using it as a hard and fast support and resistance indicator. This is not what it is for and ranges can be exceeded with momentum. The key is looking for whether ranges are exceeded (i.e. high momentum, thus breakout play) or they are not (thus low volume, rangy).
Using it for longer term outlooks. This is not ideal for long term ranges, as with any Bollinger/standard deviation based approach, it is only responsive to CURRENT PA and cannot forecast FUTURE PA.
User Inputs
The indicator is really straight forward. There are 2 optional inputs and 1 required input.
Period Selection: Required. Selects the period for the indicator to perform the analysis on. You just select it with your mouse on the chart.
Visible MA: Optional. You can choose to have the breakout range moving average visible or not.
Fills: Optional. You can choose to have the fills plotted or not.
And that is the indicator! Very easy to use and hope you enjoy and find it helpful!
As always, safe trades everyone! 🚀
Quad Rotation StochasticQuad Rotation Stochastic
The Quad Rotation Stochastic is a powerful and unique momentum oscillator that combines four different stochastic setups into one tool, providing an incredibly detailed view of market conditions. This multi-timeframe stochastic approach helps traders better anticipate trend continuations, reversals, and momentum shifts with greater precision than traditional single stochastic indicators.
Why this indicator is useful:
Multi-layered Momentum Analysis: Instead of relying on one stochastic, this script tracks four independent stochastic readings, smoothing out noise and confirming stronger signals.
Advanced Divergence Detection: It automatically identifies bullish and bearish divergences for each stochastic, helping traders spot potential reversals early.
Background Color Alerts: When a configurable number (e.g., 3 or 4) of the stochastics agree in direction and position (overbought/oversold), the background colors green (bullish) or red (bearish) to give instant visual cues.
ABCD Pattern Recognition: The script recognizes "shield" patterns when Stochastic 4 remains stuck at extreme levels (above 90 or below 10) for a set time, warning of potential trend continuation setups.
Super Signal Alerts: If all four stochastics align in extreme conditions and slope in the same direction, the indicator plots a special "Super Signal," offering high-confidence entry opportunities.
Why this indicator is unique:
Quad Confirmation Logic: Combining four different stochastics makes this tool much less prone to false signals compared to using a single stochastic.
Customizable Divergence Coloring: Traders can choose to have divergence lines automatically match the stochastic color for clear visual association.
Adaptive ABCD Shields: Innovative use of bar counting while a stochastic remains extreme acts as a "shield," offering a unique way to filter out minor fake-outs.
Flexible Configuration: Each stochastic's sensitivity, divergence settings, and visual styling can be fully customized, allowing traders to adapt it to their own strategy and asset.
Example Usage: Trading Bitcoin with Quad Rotation Stochastic
When trading Bitcoin (BTCUSD), you might set the minimum count (minCount) to 3, meaning three out of four stochastics must be in agreement to trigger a background color.
If the background turns green, and you notice an ABCD Bullish Shield (Green X), you might look for bullish candlestick patterns or moving average crossovers to enter a long trade.
Conversely, if the background turns red and a Super Down Signal appears, it suggests high probability for further downside, giving you strong confirmation to either short BTC or avoid entering new longs.
By combining divergence signals with background colors and the ABCD shields, the Quad Rotation Stochastic provides a layered confirmation system that gives traders greater confidence in their entries and exits — particularly in fast-moving, volatile markets like Bitcoin.