INVITE-ONLY SCRIPT
QV 1W/1M 2BX & FVB Strategy

Use on Weekly Timeframe
### Overview of the Strategy
The "QV 1W/1M 2BX & FVB Strategy" is a TradingView Pine Script (version 5) strategy designed for trend-following trading on financial instruments like stocks, forex, or cryptocurrencies. It supports both long and short directions (user-selectable via input), with a focus on multi-timeframe momentum analysis using custom oscillators (called "Xtrender"), a volatility-based trailing line (Red ATR), Fair Value Bands (FVB) for deviation-based targets, and Break of Structure (BOS) for invalidation. The strategy allows pyramiding (adding to positions) and includes multiple exit mechanisms, including full exits and partial scale-outs. It's optimized for higher timeframes like weekly (1W) and monthly (1M) by default, but can be customized.
The strategy overlays indicators on the chart but runs in a non-overlay mode for its own panel (showing histograms). It uses 5% of equity per trade by default, with pyramiding limited to one additional entry (effectively doubling the position). It incorporates risk management through ATR-based stops and band deviations, and provides alerts for key events like band touches or BOS breaks.
The name likely refers to:
- **1W/1M**: Default timeframes for the two Xtrender oscillators.
- **2BX**: Dual "B-Xtrender" oscillators (short-term on two timeframes).
- **FVB**: Fair Value Bands for scaling out.
It assumes good intent for directional trading and doesn't enforce drawdown limits beyond the exits.
### Key Indicators and Calculations
The strategy relies on several custom indicators to generate signals:
1. **Short-Term Xtrender Oscillators**:
- These are momentum indicators based on RSI of the difference between two EMAs (Exponential Moving Averages), shifted by -50 to center around zero.
- **TF1 (e.g., 1W)**: Calculated as `RSI(EMA(close, short_l1) - EMA(close, short_l2), short_l3) - 50`, fetched from the specified timeframe.
- **TF2 (e.g., 1M)**: Same formula, but on a higher timeframe for broader trend confirmation.
- A combined version sums them for potential use, but the strategy primarily uses them separately.
- Plotted as histograms: Green shades for positive/upward momentum (brighter for 2-bar increases or zero crosses), red shades for negative/downward.
- TF2 direction persists across bars to detect if it's increasing or decreasing.
2. **Long-Term Xtrender**:
- Simpler RSI of an EMA: `RSI(EMA(close, long_l1), long_l2)`.
- Not directly used in entries/exits in this script (possibly a remnant or for visualization).
3. **Red ATR Line**:
- A volatility-based trailing line, similar to SuperTrend.
- Calculated using ATR (Average True Range) over a length (default 10), multiplied by a factor (default 2.5).
- It flips direction based on price closes above/below the previous line value, creating an upper/lower bound.
- Plotted as a red line on the price chart (overlay=true).
- Used for entries (pyramiding on cross), exits (full exit on adverse cross), and conditional checks.
4. **Fair Value Bands (FVB)**:
- Based on a smoothed "fair price" (SMA of OHLC4 over fair_value_length, default 33).
- Calculates median deviations from this fair price using historical high/low spreads and pivot highs/lows.
- Creates three upper bands (for longs) and three lower bands (for shorts) at multipliers (0.6x, 1.0x, 1.4x by default).
- Upper bands: Fair price + deviation spreads (boosted for pivots outside bands).
- Lower bands: Fair price - deviation spreads.
- Plotted in yellow/orange/red gradients, visible only for the selected direction.
- Used for scale-out exits and re-entry conditions after full exits.
5. **Break of Structure (BOS)**:
- Tracks the last swing low (for longs) or swing high (for shorts) using pivotlow/pivothigh over 5 bars left/right.
- Plotted as a white line if enabled.
- Acts as a support/resistance level for invalidation exits.
6. **2-Bar Conditions**:
- For longs: TF1 Xtrender red (below 0) and decreasing for two consecutive bars.
- For shorts: TF1 Xtrender green (above 0) and increasing for two consecutive bars.
- Used for adverse momentum exits.
7. **Other Checks**:
- TF1 cross above/below zero.
- Large changes in TF1 Xtrender (greater than exit_amount, default 40).
A custom T3 (Tillson T3) smoothing function is defined but not used in the visible code—possibly for future extensions.
### How the Strategy Works: Entries
The strategy enters positions based on momentum alignment across timeframes, with safeguards to avoid re-entering immediately after full exits.
- **Direction Selection**:
- User chooses "Long" or "Short" via input. The strategy only trades in that direction.
- **Main Entry** (if enabled):
- **For Longs**:
- TF2 Xtrender is increasing (change > 0) or above a threshold (default 10).
- TF1 Xtrender is increasing (current > previous).
- No existing long position (position_size <= 0).
- If previously fully exited a long, price must be <= 2x upper band (upper2) to re-enter.
- **For Shorts**:
- TF2 Xtrender is decreasing (change < 0) or below -threshold.
- TF1 Xtrender is decreasing (current < previous).
- No existing short position (position_size >= 0).
- If previously fully exited a short, price must be >= 2x lower band (lower2) to re-enter.
- Entry size: 5% of equity (default).
- **Pyramiding** (if enabled):
- Adds one more entry (doubling the position) when price crosses the Red ATR line in the favorable direction.
- For longs: Crossover above Red ATR.
- For shorts: Crossunder below Red ATR.
- Tracks initial quantity to ensure only one add-on per trade cycle.
- Pyramiding limit: 1 (as set in strategy declaration).
Upon entry, it records the initial position size, resets flags for scaling/exiting, and sets the BOS level (last swing low/high).
### How the Strategy Works: Exits
Exits are modular, with toggles for each type. Full exits set a "has_fully_exited" flag to prevent immediate re-entries until price retraces to the 2x band. Partial scale-outs (50%) can repeat unlimited times if price oscillates around bands.
- **Full Exits** (close entire position, mark as fully exited):
1. **ATR Exit** (if enabled): Adverse cross of Red ATR (e.g., close below for longs).
2. **2-Bar Exit** (if enabled): Adverse 2-bar momentum in TF1, and price below/above Red ATR (e.g., red and decreasing for longs).
3. **TF1 Below/Above Zero Exit** (if enabled): TF1 crosses zero adversely, only if price is on the wrong side of Red ATR.
4. **Large TF1 Change Exit** (if enabled): Adverse large drop/rise in TF1 (> exit_amount).
5. **BOS Exit** (if enabled): Price crosses BOS level adversely (e.g., below swing low for longs).
6. **3x Band Exit** (if enabled): Price crosses above 3x band (for longs) or below (for shorts), but waits for a cross back inside to exit fully.
- **Partial Scale-Outs** (50% of current position, repeatable):
1. **1x Band** (if enabled): Cross above 1x upper (longs) or below 1x lower (shorts), then cross back inside.
2. **2x Band** (if enabled): Similar logic for 2x bands.
Exits use waiting flags to detect the full cross-and-return cycle, ensuring they trigger only after touching and retreating from the band.
### Alerts
- **Band Touch Alerts** (if enabled): Triggers on price touching any 1x/2x/3x upper/lower band from above or below (real-time, freq_all).
- **BOS Touch Alert** (if enabled): Price touches BOS level from adverse side.
- **BOS Cross Alert** (if enabled and BOS exit on): Price crosses and closes beyond BOS (once per bar close).
- Alerts reset per new bar to allow multiple triggers if conditions recur.
### Additional Notes
- **State Management**: Uses `var` variables for persistent states like TF2 direction, swing levels, position tracking, and alert flags.
- **Visualization**: Histograms for Xtrenders, lines for Red ATR, Fair Value (blue middle), bands (colored), and BOS (white).
- **Customization**: All key params (lengths, multis, thresholds) are inputs. Disabling features simplifies the strategy.
- **Limitations**: No built-in stop-loss beyond BOS/ATR; relies on equity percent sizing. Assumes chart timeframe is lower than TF1/TF2 for security requests.
- **Performance**: Backtesting would depend on the asset and settings—e.g., works best in trending markets due to momentum filters.
This strategy combines trend confirmation (multi-TF oscillators), volatility trailing (Red ATR), and deviation targets (FVB) for a balanced approach to capturing moves while scaling out profits and cutting losses on reversals.
### Overview of the Strategy
The "QV 1W/1M 2BX & FVB Strategy" is a TradingView Pine Script (version 5) strategy designed for trend-following trading on financial instruments like stocks, forex, or cryptocurrencies. It supports both long and short directions (user-selectable via input), with a focus on multi-timeframe momentum analysis using custom oscillators (called "Xtrender"), a volatility-based trailing line (Red ATR), Fair Value Bands (FVB) for deviation-based targets, and Break of Structure (BOS) for invalidation. The strategy allows pyramiding (adding to positions) and includes multiple exit mechanisms, including full exits and partial scale-outs. It's optimized for higher timeframes like weekly (1W) and monthly (1M) by default, but can be customized.
The strategy overlays indicators on the chart but runs in a non-overlay mode for its own panel (showing histograms). It uses 5% of equity per trade by default, with pyramiding limited to one additional entry (effectively doubling the position). It incorporates risk management through ATR-based stops and band deviations, and provides alerts for key events like band touches or BOS breaks.
The name likely refers to:
- **1W/1M**: Default timeframes for the two Xtrender oscillators.
- **2BX**: Dual "B-Xtrender" oscillators (short-term on two timeframes).
- **FVB**: Fair Value Bands for scaling out.
It assumes good intent for directional trading and doesn't enforce drawdown limits beyond the exits.
### Key Indicators and Calculations
The strategy relies on several custom indicators to generate signals:
1. **Short-Term Xtrender Oscillators**:
- These are momentum indicators based on RSI of the difference between two EMAs (Exponential Moving Averages), shifted by -50 to center around zero.
- **TF1 (e.g., 1W)**: Calculated as `RSI(EMA(close, short_l1) - EMA(close, short_l2), short_l3) - 50`, fetched from the specified timeframe.
- **TF2 (e.g., 1M)**: Same formula, but on a higher timeframe for broader trend confirmation.
- A combined version sums them for potential use, but the strategy primarily uses them separately.
- Plotted as histograms: Green shades for positive/upward momentum (brighter for 2-bar increases or zero crosses), red shades for negative/downward.
- TF2 direction persists across bars to detect if it's increasing or decreasing.
2. **Long-Term Xtrender**:
- Simpler RSI of an EMA: `RSI(EMA(close, long_l1), long_l2)`.
- Not directly used in entries/exits in this script (possibly a remnant or for visualization).
3. **Red ATR Line**:
- A volatility-based trailing line, similar to SuperTrend.
- Calculated using ATR (Average True Range) over a length (default 10), multiplied by a factor (default 2.5).
- It flips direction based on price closes above/below the previous line value, creating an upper/lower bound.
- Plotted as a red line on the price chart (overlay=true).
- Used for entries (pyramiding on cross), exits (full exit on adverse cross), and conditional checks.
4. **Fair Value Bands (FVB)**:
- Based on a smoothed "fair price" (SMA of OHLC4 over fair_value_length, default 33).
- Calculates median deviations from this fair price using historical high/low spreads and pivot highs/lows.
- Creates three upper bands (for longs) and three lower bands (for shorts) at multipliers (0.6x, 1.0x, 1.4x by default).
- Upper bands: Fair price + deviation spreads (boosted for pivots outside bands).
- Lower bands: Fair price - deviation spreads.
- Plotted in yellow/orange/red gradients, visible only for the selected direction.
- Used for scale-out exits and re-entry conditions after full exits.
5. **Break of Structure (BOS)**:
- Tracks the last swing low (for longs) or swing high (for shorts) using pivotlow/pivothigh over 5 bars left/right.
- Plotted as a white line if enabled.
- Acts as a support/resistance level for invalidation exits.
6. **2-Bar Conditions**:
- For longs: TF1 Xtrender red (below 0) and decreasing for two consecutive bars.
- For shorts: TF1 Xtrender green (above 0) and increasing for two consecutive bars.
- Used for adverse momentum exits.
7. **Other Checks**:
- TF1 cross above/below zero.
- Large changes in TF1 Xtrender (greater than exit_amount, default 40).
A custom T3 (Tillson T3) smoothing function is defined but not used in the visible code—possibly for future extensions.
### How the Strategy Works: Entries
The strategy enters positions based on momentum alignment across timeframes, with safeguards to avoid re-entering immediately after full exits.
- **Direction Selection**:
- User chooses "Long" or "Short" via input. The strategy only trades in that direction.
- **Main Entry** (if enabled):
- **For Longs**:
- TF2 Xtrender is increasing (change > 0) or above a threshold (default 10).
- TF1 Xtrender is increasing (current > previous).
- No existing long position (position_size <= 0).
- If previously fully exited a long, price must be <= 2x upper band (upper2) to re-enter.
- **For Shorts**:
- TF2 Xtrender is decreasing (change < 0) or below -threshold.
- TF1 Xtrender is decreasing (current < previous).
- No existing short position (position_size >= 0).
- If previously fully exited a short, price must be >= 2x lower band (lower2) to re-enter.
- Entry size: 5% of equity (default).
- **Pyramiding** (if enabled):
- Adds one more entry (doubling the position) when price crosses the Red ATR line in the favorable direction.
- For longs: Crossover above Red ATR.
- For shorts: Crossunder below Red ATR.
- Tracks initial quantity to ensure only one add-on per trade cycle.
- Pyramiding limit: 1 (as set in strategy declaration).
Upon entry, it records the initial position size, resets flags for scaling/exiting, and sets the BOS level (last swing low/high).
### How the Strategy Works: Exits
Exits are modular, with toggles for each type. Full exits set a "has_fully_exited" flag to prevent immediate re-entries until price retraces to the 2x band. Partial scale-outs (50%) can repeat unlimited times if price oscillates around bands.
- **Full Exits** (close entire position, mark as fully exited):
1. **ATR Exit** (if enabled): Adverse cross of Red ATR (e.g., close below for longs).
2. **2-Bar Exit** (if enabled): Adverse 2-bar momentum in TF1, and price below/above Red ATR (e.g., red and decreasing for longs).
3. **TF1 Below/Above Zero Exit** (if enabled): TF1 crosses zero adversely, only if price is on the wrong side of Red ATR.
4. **Large TF1 Change Exit** (if enabled): Adverse large drop/rise in TF1 (> exit_amount).
5. **BOS Exit** (if enabled): Price crosses BOS level adversely (e.g., below swing low for longs).
6. **3x Band Exit** (if enabled): Price crosses above 3x band (for longs) or below (for shorts), but waits for a cross back inside to exit fully.
- **Partial Scale-Outs** (50% of current position, repeatable):
1. **1x Band** (if enabled): Cross above 1x upper (longs) or below 1x lower (shorts), then cross back inside.
2. **2x Band** (if enabled): Similar logic for 2x bands.
Exits use waiting flags to detect the full cross-and-return cycle, ensuring they trigger only after touching and retreating from the band.
### Alerts
- **Band Touch Alerts** (if enabled): Triggers on price touching any 1x/2x/3x upper/lower band from above or below (real-time, freq_all).
- **BOS Touch Alert** (if enabled): Price touches BOS level from adverse side.
- **BOS Cross Alert** (if enabled and BOS exit on): Price crosses and closes beyond BOS (once per bar close).
- Alerts reset per new bar to allow multiple triggers if conditions recur.
### Additional Notes
- **State Management**: Uses `var` variables for persistent states like TF2 direction, swing levels, position tracking, and alert flags.
- **Visualization**: Histograms for Xtrenders, lines for Red ATR, Fair Value (blue middle), bands (colored), and BOS (white).
- **Customization**: All key params (lengths, multis, thresholds) are inputs. Disabling features simplifies the strategy.
- **Limitations**: No built-in stop-loss beyond BOS/ATR; relies on equity percent sizing. Assumes chart timeframe is lower than TF1/TF2 for security requests.
- **Performance**: Backtesting would depend on the asset and settings—e.g., works best in trending markets due to momentum filters.
This strategy combines trend confirmation (multi-TF oscillators), volatility trailing (Red ATR), and deviation targets (FVB) for a balanced approach to capturing moves while scaling out profits and cutting losses on reversals.
僅限邀請腳本
只有經作者批准的使用者才能訪問此腳本。您需要申請並獲得使用權限。該權限通常在付款後授予。如欲了解更多詳情,請依照以下作者的說明操作,或直接聯絡QuantVault。
除非您完全信任其作者並了解腳本的工作原理,否則TradingView不建議您付費或使用腳本。您也可以在我們的社群腳本中找到免費的開源替代方案。
作者的說明
To get the QV 1W/1M 2BX & FVB Strategy, subscribe at quant-vault.com. This site offers paid access to TradingView Pine Scripts like this one for trend trading in stocks, forex, and crypto.
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。
僅限邀請腳本
只有經作者批准的使用者才能訪問此腳本。您需要申請並獲得使用權限。該權限通常在付款後授予。如欲了解更多詳情,請依照以下作者的說明操作,或直接聯絡QuantVault。
除非您完全信任其作者並了解腳本的工作原理,否則TradingView不建議您付費或使用腳本。您也可以在我們的社群腳本中找到免費的開源替代方案。
作者的說明
To get the QV 1W/1M 2BX & FVB Strategy, subscribe at quant-vault.com. This site offers paid access to TradingView Pine Scripts like this one for trend trading in stocks, forex, and crypto.
免責聲明
這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。