OPEN-SOURCE SCRIPT

200 EMA and MACD Arrow Indicator with HTF Filter

The "200 EMA and MACD Arrow Indicator with Higher Time Frame (HTF) Filter" is designed to provide trading signals for better trend alignment and reduce choppy market noise by using both current and higher timeframe indicators. This script incorporates the following features:

EMA 200 Trend Indicator: Calculates the 200-period Exponential Moving Average (EMA) to identify the current trend direction on the chart timeframe. The EMA changes color dynamically:

Green for a strong uptrend.
Red for a strong downtrend.
Gray for neutral or choppy markets.
Higher Time Frame (HTF) Trend Filter: Utilizes a higher timeframe (currently set to 1 hour) to verify the direction of the larger trend using the same logic as the 200 EMA. The background color of the chart changes based on the HTF trend:

Light Green indicates an uptrend.
Light Red indicates a downtrend.
Light Gray indicates a choppy or neutral market.
MACD Crossover Signals: The script uses the MACD (Moving Average Convergence Divergence) with a standard setting (12, 26, 9) to generate buy and sell signals.

Buy Signal: Occurs when:
The price is above the 200 EMA.
MACD crosses above the signal line while below zero.
The HTF trend is aligned (uptrend).
The lower timeframe EMA is green.
Sell Signal: Occurs when:
The price is below the 200 EMA.
MACD crosses below the signal line while above zero.
The HTF trend is aligned (downtrend).
The lower timeframe EMA is red.
Visual Signals on Chart: When all conditions are met for a buy or sell, an arrow is plotted on the chart:

Green Arrow (Buy Signal): Plotted above the candle when the buy condition is met.
Red Arrow (Sell Signal): Plotted below the candle when the sell condition is met.
multitimeframeTrend Analysis

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