OPEN-SOURCE SCRIPT

Filtered MACD with Backtest [UAlgo]

Aktualisiert
The "Filtered MACD with Backtest [UAlgo]" indicator is an advanced trading tool designed for the TradingView platform. It combines the Moving Average Convergence Divergence (MACD) with additional filters such as Moving Average (MA) and Average Directional Index (ADX) to enhance trading signals. This indicator aims to provide more reliable entry and exit points by filtering out noise and confirming trends. Additionally, it includes a comprehensive backtesting module to simulate trading strategies and assess their performance based on historical data. The visual backtest module allows traders to see potential trades directly on the chart, making it easier to evaluate the effectiveness of the strategy.

🔶 Customizable Parameters :

Price Source Selection: Users can choose their preferred price source for calculations, providing flexibility in analysis.

Filter Parameters:

MA Filter: Option to use a Moving Average filter with types such as EMA, SMA, WMA, RMA, and VWMA, and a customizable length.

ADX Filter: Option to use an ADX filter with adjustable length and threshold to determine trend strength.

MACD Parameters: Customizable fast length, slow length, and signal smoothing for the MACD indicator.

Backtest Module:

Entry Type: Supports "Buy and Sell", "Buy", and "Sell" strategies.

Stop Loss Types: Choose from ATR-based, fixed point, or X bar high/low stop loss methods.

Reward to Risk Ratio: Set the desired take profit level relative to the stop loss.

Backtest Visuals: Display entry, stop loss, and take profit levels directly on the chart with
colored backgrounds.

Alerts: Configurable alerts for buy and sell signals.

🔶 Filtered MACD : Understanding How Filters Work with ADX and MA

ADX Filter:

The Average Directional Index (ADX) measures the strength of a trend. The script calculates ADX using the user-defined length and applies a threshold value.

Trading Signals with ADX Filter:

Buy Signal: A regular MACD buy signal (crossover of MACD line above the signal line) is only considered valid if the ADX is above the set threshold. This suggests a stronger uptrend to potentially capitalize on.

Sell Signal: Conversely, a regular MACD sell signal (crossunder of MACD line below the signal line) is only considered valid if the ADX is above the threshold, indicating a stronger downtrend for potential shorting opportunities.

Benefits: The ADX filter helps avoid whipsaws or false signals that might occur during choppy market conditions with weak trends.

Snapshot

Snapshot

MA Filter:

You can choose from various Moving Average (MA) types (EMA, SMA, WMA, RMA, VWMA) for the filter. The script calculates the chosen MA based on the user-defined length.

Trading Signals with MA Filter:

Buy Signal: A regular MACD buy signal is only considered valid if the closing price is above the MA value. This suggests a potential uptrend confirmed by the price action staying above the moving average.

Sell Signal: Conversely, a regular MACD sell signal is only considered valid if the closing price is below the MA value. This suggests a potential downtrend confirmed by the price action staying below the moving average.

Benefits: The MA filter helps identify potential trend continuation opportunities by ensuring the price aligns with the chosen moving average direction.

Snapshot

Snapshot

Combining Filters:

You can choose to use either the ADX filter, the MA filter, or both depending on your strategy preference. Using both filters adds an extra layer of confirmation for your signals.

🔶 Backtesting Module

The backtesting module in this script allows you to visually assess how the filtered MACD strategy would have performed on historical data. Here's a deeper dive into its features:

Backtesting Type: You can choose to backtest for buy signals only, sell signals only, or both. This allows you to analyze the strategy's effectiveness in different market conditions.

Stop-Loss Types: You can define how stop-loss orders are placed:

ATR (Average True Range): This uses a volatility measure (ATR) multiplied by a user-defined factor to set the stop-loss level.

Fixed Point: This allows you to specify a fixed dollar amount or percentage value as the stop-loss.

X bar High/Low: This sets the stop-loss at a certain number of bars (defined by the user) above/below the bar's high (for long positions) or low (for short positions).

Reward-to-Risk Ratio: Define the desired ratio between your potential profit and potential loss on each trade. The backtesting module will calculate take-profit levels based on this ratio and the stop-loss placement.

Snapshot

🔶 Disclaimer:

Use with Caution: This indicator is provided for educational and informational purposes only and should not be considered as financial advice. Users should exercise caution and perform their own analysis before making trading decisions based on the indicator's signals.

Not Financial Advice: The information provided by this indicator does not constitute financial advice, and the creator (UAlgo) shall not be held responsible for any trading losses incurred as a result of using this indicator.

Backtesting Recommended: Traders are encouraged to backtest the indicator thoroughly on historical data before using it in live trading to assess its performance and suitability for their trading strategies.

Risk Management: Trading involves inherent risks, and users should implement proper risk management strategies, including but not limited to stop-loss orders and position sizing, to mitigate potential losses.

No Guarantees: The accuracy and reliability of the indicator's signals cannot be guaranteed, as they are based on historical price data and past performance may not be indicative of future results.
Versionshinweise
Added license and trademark.
ADXATRAverage Directional Index (ADX)backtestexponentialmovingaveragefilterMoving Average Convergence / Divergence (MACD)Simple Moving Average (SMA)trendstrength

Open-source Skript

Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun das Script auch andere Trader verstehen und prüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden. Die Nutzung dieses Codes in einer Veröffentlichung wird in unseren Hausregeln reguliert. Sie können es als Favoriten auswählen, um es in einem Chart zu verwenden.

Möchten Sie dieses Skript auf einem Chart verwenden?


Get access to our exclusive tools: ualgo.trade

Join Our Discord For Updates: discord.com/invite/kyQkKxUQkW

All scripts & Content Provided by UAlgo Are For Informational & Educational Purposes Only.
Auch am:

Haftungsausschluss