OPEN-SOURCE SCRIPT

Supertrend and Fast and Slow EMA Strategy

136
This strategy combines Exponential Moving Averages (EMAs) and Average True Range (ATR) to create a simple, yet effective, trend-following approach. The strategy filters out fake or sideways signals by incorporating the ATR as a volatility filter, ensuring that trades are only taken during trending conditions. The key idea is to buy when the short-term trend (Fast EMA) aligns with the long-term trend (Slow EMA), and to avoid trades during low volatility periods.

How It Works:

EMA Crossover:

1). Buy Signal: When the Fast EMA (shorter-term, e.g., 20-period) crosses above the Slow EMA (longer-term, e.g., 50-period), this indicates a potential uptrend.
2). Sell Signal: When the Fast EMA crosses below the Slow EMA, this indicates a potential downtrend.

ATR Filter:

1). The ATR (Average True Range) is used to measure market volatility.
2). Trending Market: If the ATR is above a certain threshold, it indicates high volatility and a trending market. Only when ATR is above the threshold will the strategy generate buy/sell signals.
3). Sideways Market: If ATR is low (sideways or choppy market), the strategy will suppress signals to avoid entering during non-trending conditions.

When to Buy:

1). Condition 1: The Fast EMA crosses above the Slow EMA.
2). Condition 2: The ATR is above the defined threshold, indicating that the market is trending (not sideways or choppy).

When to Sell:

1). Condition 1: The Fast EMA crosses below the Slow EMA.
2). Condition 2: The ATR is above the defined threshold, confirming that the market is in a downtrend.

When Not to Enter the Trade:

1). Sideways Market: If the ATR is below the threshold, signaling low volatility and sideways or choppy market conditions, the strategy will not trigger any buy or sell signals.
2). False Crossovers: In low volatility conditions, price action tends to be noisy, which could lead to false signals. Therefore, avoiding trades during these periods reduces the risk of false breakouts.

Additional Factors to Consider Adding:

=> RSI (Relative Strength Index): Adding an RSI filter can help confirm overbought or oversold conditions to avoid buying into overextended moves or selling too low.

1). RSI Buy Filter: Only take buy signals when RSI is below 70 (avoiding overbought conditions).
2). RSI Sell Filter: Only take sell signals when RSI is above 30 (avoiding oversold conditions).

=> MACD (Moving Average Convergence Divergence): Using MACD can help validate the strength of the trend.

1). Buy when the MACD histogram is above the zero line and the Fast EMA crosses above the Slow EMA.
2). Sell when the MACD histogram is below the zero line and the Fast EMA crosses below the Slow EMA.

=> Support/Resistance Levels: Adding support and resistance levels can help you understand market structure and decide whether to enter or exit a trade.

1). Buy when price breaks above a significant resistance level (after a valid buy signal).
2). Sell when price breaks below a major support level (after a valid sell signal).

=> Volume: Consider adding a volume filter to ensure that buy/sell signals are supported by strong market participation. You could only take signals if the volume is above the moving average of volume over a certain period.

=> Trailing Stop Loss: Instead of a fixed stop loss, use a trailing stop based on a percentage or ATR to lock in profits as the trade moves in your favor.

=> Exit Signals: Besides the EMA crossover, consider adding Take Profit or Stop Loss levels, or even using a secondary indicator like RSI to signal an overbought/oversold condition and exit the trade.

Example Usage:

=> Buy Example:

1). Fast EMA (20-period) crosses above the Slow EMA (50-period).
2). The ATR is above the threshold, confirming that the market is trending.
3). Optionally, if RSI is below 70, the buy signal is further confirmed as not being overbought.

=> Sell Example:

1). Fast EMA (20-period) crosses below the Slow EMA (50-period).
2). The ATR is above the threshold, confirming that the market is trending.
3). Optionally, if RSI is above 30, the sell signal is further confirmed as not being oversold.

Conclusion:

This strategy helps to identify trending markets and filters out sideways or choppy market conditions. By using Fast and Slow EMAs combined with the ATR volatility filter, it provides a reliable approach to catching trending moves while avoiding false signals during low-volatility, sideways markets.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.