OPEN-SOURCE SCRIPT

Custom EMA/ATR/Keltner/Bollinger with Squeeze Setup

21-EMA and ATR-Based Analysis
21-EMA (Exponential Moving Average):

Acts as a dynamic support/resistance level.
The price's relationship with the 21-EMA is used to detect trends and potential reversals.
ATR (Average True Range):

Measures volatility.
Used to define price thresholds for buy/sell conditions (e.g., price not more than 1 ATR above 21-EMA for a buy signal).
2. Bollinger Bands and Keltner Channels for Squeeze Setup
Bollinger Bands (BB):

Calculated using a 20-period simple moving average and standard deviations.
Represents high and low volatility zones.
Keltner Channels (KC):

Based on a 20-period EMA and ATR.
Provides narrower channels for price action compared to Bollinger Bands.
Squeeze Condition:

Occurs when Bollinger Bands fall inside Keltner Channels, signaling low volatility.
These periods often precede significant price movements (breakouts).
3. Momentum Indicator (MACD Histogram)
MACD Histogram:
Measures momentum during a squeeze.
Positive histogram values suggest bullish momentum, while negative values suggest bearish momentum.
Used to predict breakout direction from a squeeze.
4. RSI (Relative Strength Index) for Overbought/Oversold Conditions
Buy Signal:
RSI below 50 indicates a potential oversold condition, supporting a buy signal.
Sell Signal:
RSI above 80 indicates overbought conditions, supporting a sell signal.
5. Buy/Sell Signal Conditions
Buy Signal:

Price is not more than 1 ATR above the 21-EMA.
RSI is below 50 (oversold).
Price touches the 21-EMA within a small tolerance.
Squeeze condition is active.
Sell Signal:

Price is 3 ATR above the 21-EMA.
RSI is above 80 (overbought).
Additional Signals:

Buy: Price is 2 standard deviations below the 21-EMA.
Sell: Price is 2 standard deviations above the 21-EMA.
6. Visual Enhancements
Chart patternsforecastingMoving Averages

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer