OPEN-SOURCE SCRIPT
Cheat Setup

//version=5
indicator("Cheat Setup", overlay=true)
// === User inputs ===
adr_period = input.int(20, title="ADR Window (days)")
lookback = input.int(100, title="Historical Lookback (bars)")
sensitivity = input.float(1.5, minval=0.5, step=0.1, title="Sensitivity (Multiplier of Avg ADR%)")
show_threshold_lines = input.bool(true, title="Show ADR% / Threshold Lines")
// === ADR% Calculation ===
// ADR% = (20-day high - 20-day low) / 20-day low × 100
adr_percent = (ta.highest(high, adr_period) - ta.lowest(low, adr_period)) / ta.lowest(low, adr_period) * 100
// Average ADR% over lookback period
avg_adr_percent = ta.sma(adr_percent, lookback)
// Adaptive threshold
adaptive_threshold = avg_adr_percent * sensitivity
// Detection condition
cheat_setup_signal = adr_percent > adaptive_threshold
// === Plotting ===
bgcolor(cheat_setup_signal ? color.new(color.green, 80) : na, title="Cheat Setup Background")
// Optional: Visual aid lines
plot(show_threshold_lines ? adr_percent : na, title="ADR(20)%", color=color.orange)
plot(show_threshold_lines ? avg_adr_percent : na, title="Average ADR%", color=color.gray)
plot(show_threshold_lines ? adaptive_threshold : na, title="Adaptive Threshold", color=color.red)
// ## What This Script Is For
// This script helps detect potential breakout zones — often called a "Cheat Setup" — before they happen.
// It's useful for identifying periods where a stock's volatility starts expanding after consolidation, which often leads to a breakout.
// ## What Is a Cheat Setup?
// A Cheat Setup is a technical setup where:
// > The price has been consolidating within a narrow range.
// > When volatility suddenly increases, it may indicate a breakout is about to occur.
// This script alerts you when that volatility expansion begins, using an adaptive threshold.
// ## How the Script Works (Step by Step)
// 1. Calculates ADR%:
// Measures how much the price has moved over the past N days (default: 20),
// using the formula: (20-day high - 20-day low) ÷ 20-day low × 100
// 2. Calculates the average ADR% over a longer lookback period (default: 100 bars).
// 3. Sets an adaptive threshold:
// The average ADR% multiplied by a user-defined sensitivity factor (e.g. 1.5×).
// 4. Triggers a cheat setup signal if the current ADR% exceeds the threshold.
// 5. Displays a green background on the chart during the signal to visually highlight the cheat area.
// 6. Optionally draws 3 reference lines:
// - Current ADR% (orange line)
// - Average ADR% (gray line)
// - Adaptive threshold (red line)
// ## How to Use the Script
// 1. Apply the script on a TradingView chart (daily timeframe is recommended).
// 2. Select a stock (e.g. AAPL, TSLA, 0700, 9988).
// 3. Monitor for periods when the background turns green.
// 4. These green zones signal that volatility has increased — the stock may be preparing for a breakout.
// ## What to Do When You See a Green Background
// - Add the stock to your watchlist.
// - Wait for confirmation — such as a breakout above the recent consolidation range.
// - Use other indicators like RSI, volume, or moving averages to filter signals.
// - Avoid chasing; instead, use the green zone as early warning and plan your entry.
// ## Recommended Parameter Settings
// Parameter | Purpose
// ---------------------- | ---------------------------------------------------------------
// `adr_period` | Number of days to calculate ADR%, e.g. 20
// `lookback` | Number of bars to average ADR%, e.g. 100
// `sensitivity` | Multiplier for adaptive threshold. 1.5 = moderate, 2.0 = strict
// `show_threshold_lines` | Toggle visibility of the ADR%, average, and threshold lines
// If the signal appears too frequently, increase the `sensitivity`. If too few, lower it slightly.
// ## Summary
// This script identifies stocks that are showing early signs of a breakout based on abnormal volatility expansion.
// It's especially useful for traders who want to get ahead of the move — before a breakout occurs — rather than reacting to it afterward.
// If you'd like, I can extend this script to also include:
// - Volume filters
// - Consolidation zone detection
// - Alert setup
// - Breakout confirmation (e.g. close > recent high)
// Let me know if you want to take it further.
indicator("Cheat Setup", overlay=true)
// === User inputs ===
adr_period = input.int(20, title="ADR Window (days)")
lookback = input.int(100, title="Historical Lookback (bars)")
sensitivity = input.float(1.5, minval=0.5, step=0.1, title="Sensitivity (Multiplier of Avg ADR%)")
show_threshold_lines = input.bool(true, title="Show ADR% / Threshold Lines")
// === ADR% Calculation ===
// ADR% = (20-day high - 20-day low) / 20-day low × 100
adr_percent = (ta.highest(high, adr_period) - ta.lowest(low, adr_period)) / ta.lowest(low, adr_period) * 100
// Average ADR% over lookback period
avg_adr_percent = ta.sma(adr_percent, lookback)
// Adaptive threshold
adaptive_threshold = avg_adr_percent * sensitivity
// Detection condition
cheat_setup_signal = adr_percent > adaptive_threshold
// === Plotting ===
bgcolor(cheat_setup_signal ? color.new(color.green, 80) : na, title="Cheat Setup Background")
// Optional: Visual aid lines
plot(show_threshold_lines ? adr_percent : na, title="ADR(20)%", color=color.orange)
plot(show_threshold_lines ? avg_adr_percent : na, title="Average ADR%", color=color.gray)
plot(show_threshold_lines ? adaptive_threshold : na, title="Adaptive Threshold", color=color.red)
// ## What This Script Is For
// This script helps detect potential breakout zones — often called a "Cheat Setup" — before they happen.
// It's useful for identifying periods where a stock's volatility starts expanding after consolidation, which often leads to a breakout.
// ## What Is a Cheat Setup?
// A Cheat Setup is a technical setup where:
// > The price has been consolidating within a narrow range.
// > When volatility suddenly increases, it may indicate a breakout is about to occur.
// This script alerts you when that volatility expansion begins, using an adaptive threshold.
// ## How the Script Works (Step by Step)
// 1. Calculates ADR%:
// Measures how much the price has moved over the past N days (default: 20),
// using the formula: (20-day high - 20-day low) ÷ 20-day low × 100
// 2. Calculates the average ADR% over a longer lookback period (default: 100 bars).
// 3. Sets an adaptive threshold:
// The average ADR% multiplied by a user-defined sensitivity factor (e.g. 1.5×).
// 4. Triggers a cheat setup signal if the current ADR% exceeds the threshold.
// 5. Displays a green background on the chart during the signal to visually highlight the cheat area.
// 6. Optionally draws 3 reference lines:
// - Current ADR% (orange line)
// - Average ADR% (gray line)
// - Adaptive threshold (red line)
// ## How to Use the Script
// 1. Apply the script on a TradingView chart (daily timeframe is recommended).
// 2. Select a stock (e.g. AAPL, TSLA, 0700, 9988).
// 3. Monitor for periods when the background turns green.
// 4. These green zones signal that volatility has increased — the stock may be preparing for a breakout.
// ## What to Do When You See a Green Background
// - Add the stock to your watchlist.
// - Wait for confirmation — such as a breakout above the recent consolidation range.
// - Use other indicators like RSI, volume, or moving averages to filter signals.
// - Avoid chasing; instead, use the green zone as early warning and plan your entry.
// ## Recommended Parameter Settings
// Parameter | Purpose
// ---------------------- | ---------------------------------------------------------------
// `adr_period` | Number of days to calculate ADR%, e.g. 20
// `lookback` | Number of bars to average ADR%, e.g. 100
// `sensitivity` | Multiplier for adaptive threshold. 1.5 = moderate, 2.0 = strict
// `show_threshold_lines` | Toggle visibility of the ADR%, average, and threshold lines
// If the signal appears too frequently, increase the `sensitivity`. If too few, lower it slightly.
// ## Summary
// This script identifies stocks that are showing early signs of a breakout based on abnormal volatility expansion.
// It's especially useful for traders who want to get ahead of the move — before a breakout occurs — rather than reacting to it afterward.
// If you'd like, I can extend this script to also include:
// - Volume filters
// - Consolidation zone detection
// - Alert setup
// - Breakout confirmation (e.g. close > recent high)
// Let me know if you want to take it further.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuna uygun olarak, bu komut dosyasının oluşturucusu bunu açık kaynaklı hale getirmiştir, böylece yatırımcılar betiğin işlevselliğini inceleyip doğrulayabilir. Yazara saygı! Ücretsiz olarak kullanabilirsiniz, ancak kodu yeniden yayınlamanın Site Kurallarımıza tabi olduğunu unutmayın.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.