OPEN-SOURCE SCRIPT
[SM-021-v1.1] Gaussian Channel Strategy - Long & Short

This is a trend-following breakout strategy that combines a sophisticated Moving Average (the Gaussian Channel) with a momentum oscillator (Stochastic RSI).
It aims to catch strong trend moves when the price breaks outside of the volatility bands, using the Stochastic RSI to confirm sufficient momentum exists.
Here is a detailed breakdown of how the strategy works:
1. Primary Indicator: The Gaussian Channel
The core of this strategy is a custom indicator originally developed by DonovanWall. It is designed to reduce the "lag" (delay) typically found in standard moving averages while remaining very smooth.
The Filter (Middle Line): It calculates a "Pole" based Gaussian filter. If the line is sloping up, it paints green (bullish); if sloping down, it paints red (bearish).
The Bands (Volatility): It calculates a True Range (volatility) multiplier to create an Upper Band (hband) and a Lower Band (lband).
Lag Reduction: The script includes logic to artificially reduce lag or increase response speed (modeLag and modeFast inputs).
2. Secondary Indicator: Stochastic RSI
The strategy uses standard Stochastic RSI settings (14, 100, 3, 3 inputs) to measure momentum.
K Line: The primary line used for decision-making in this script.
3. Strategy Logic
Long Trade Setup (Buying)
The strategy enters a Long position when ALL of the following conditions are met:
Long Exit (Selling)
Short Trade Setup (Selling)
The strategy enters a Short position when ALL of the following conditions are met:
Short Exit (Covering)
4. Visuals & Settings
Summary
This is a momentum breakout strategy. It does not try to buy the bottom or sell the top. Instead, it waits for the trend to establish itself (Gaussian slope) and for the price to explode outside of normal volatility ranges (Bands). It uses the Stoch RSI to ensure the move has enough "juice" behind it, and it exits quickly if the price retreats back into the normal range.
It aims to catch strong trend moves when the price breaks outside of the volatility bands, using the Stochastic RSI to confirm sufficient momentum exists.
Here is a detailed breakdown of how the strategy works:
1. Primary Indicator: The Gaussian Channel
The core of this strategy is a custom indicator originally developed by DonovanWall. It is designed to reduce the "lag" (delay) typically found in standard moving averages while remaining very smooth.
The Filter (Middle Line): It calculates a "Pole" based Gaussian filter. If the line is sloping up, it paints green (bullish); if sloping down, it paints red (bearish).
The Bands (Volatility): It calculates a True Range (volatility) multiplier to create an Upper Band (hband) and a Lower Band (lband).
Lag Reduction: The script includes logic to artificially reduce lag or increase response speed (modeLag and modeFast inputs).
2. Secondary Indicator: Stochastic RSI
The strategy uses standard Stochastic RSI settings (14, 100, 3, 3 inputs) to measure momentum.
K Line: The primary line used for decision-making in this script.
3. Strategy Logic
Long Trade Setup (Buying)
The strategy enters a Long position when ALL of the following conditions are met:
- Trend is Bullish: The Gaussian Filter is sloping upwards (Green).
- Breakout: The Closing Price is above the Gaussian Upper Band (hband).
- Momentum Validation: The Stoch RSI k line is at an extreme reading (either > 80 or < 20). This implies the script looks for high volatility/momentum, regardless of whether it is traditionally "overbought" or "oversold."
- Date & Toggle: The current date is within the backtesting range, and "Enable Long Trading" is turned on.
Long Exit (Selling)
- The strategy closes the Long position when the Price crosses under the Gaussian Upper Band.
- Interpretation: It rides the breakout wave, but as soon as price weakens and falls back inside the volatility channel, the trade is closed.
Short Trade Setup (Selling)
The strategy enters a Short position when ALL of the following conditions are met:
- Trend is Bearish: The Gaussian Filter is sloping downwards (Red).
- Breakout: The Closing Price is below the Gaussian Lower Band (lband).
- Momentum Validation: The Stoch RSI k line is at an extreme reading (either > 80 or < 20).
- Date & Toggle: The current date is within the backtesting range, and "Enable Short Trading" is turned on.
Short Exit (Covering)
- The strategy closes the Short position when the Price crosses over the Gaussian Lower Band.
4. Visuals & Settings
- Chart Overlay: The bands and the middle line are plotted on the chart.
- Bar Colors: The candlesticks change color based on their position relative to the bands and the previous candle (e.g., bright green for strong bullish breakouts, bright red for strong bearish breakouts).
- Backtesting Inputs:
- Capital: Starts with $1,000.
- Position Size: Uses 100% of equity per trade.
- Date Range: Filters trades between 2018 and 2069.
Summary
This is a momentum breakout strategy. It does not try to buy the bottom or sell the top. Instead, it waits for the trend to establish itself (Gaussian slope) and for the price to explode outside of normal volatility ranges (Bands). It uses the Stoch RSI to ensure the move has enough "juice" behind it, and it exits quickly if the price retreats back into the normal range.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.