OPEN-SOURCE SCRIPT

Multi-Factor Strategy

This trading strategy combines multiple technical indicators to create a systematic approach for entering and exiting trades. The goal is to capture trends by aligning several key indicators to confirm the direction and strength of a potential trade. Below is a detailed description of how the strategy works:

Indicators Used
MACD (Moving Average Convergence Divergence):

MACD Line: The difference between the 12-period and 26-period Exponential Moving Averages (EMAs).
Signal Line: A 9-period EMA of the MACD line.

Usage: The strategy looks for crossovers between the MACD line and the Signal line as entry signals. A bullish crossover (MACD line crossing above the Signal line) indicates a potential upward movement, while a bearish crossover (MACD line crossing below the Signal line) signals a potential downward movement.

RSI (Relative Strength Index):

Usage: RSI is used to gauge the momentum of the price movement. The strategy uses specific thresholds: below 70 for long positions to avoid overbought conditions and above 30 for short positions to avoid oversold conditions.

ATR (Average True Range):

Usage: ATR measures market volatility and is used to set dynamic stop-loss and take-profit levels. A stop loss is set at 2 times the ATR, and a take profit at 3 times the ATR, ensuring that risk is managed relative to market conditions.
Simple Moving Averages (SMA):

50-day SMA: A short-term trend indicator.

200-day SMA: A long-term trend indicator.

Usage: The strategy uses the relationship between the 50-day and 200-day SMAs to determine the overall market trend. Long positions are taken when the price is above the 50-day SMA and the 50-day SMA is above the 200-day SMA, indicating an uptrend. Conversely, short positions are taken when the price is below the 50-day SMA and the 50-day SMA is below the 200-day SMA, indicating a downtrend.

Entry Conditions

Long Position:

-MACD Crossover: The MACD line crosses above the Signal line.

-RSI Confirmation: RSI is below 70, ensuring the asset is not overbought.

-SMA Confirmation: The price is above the 50-day SMA, and the 50-day SMA is above the 200-day SMA, indicating a strong uptrend.
Short Position:

MACD Crossunder: The MACD line crosses below the Signal line.
RSI Confirmation: RSI is above 30, ensuring the asset is not oversold.

SMA Confirmation: The price is below the 50-day SMA, and the 50-day SMA is below the 200-day SMA, indicating a strong downtrend.

Opposite conditions for shorts

Exit Strategy
Stop Loss: Set at 2 times the ATR from the entry price. This dynamically adjusts to market volatility, allowing for wider stops in volatile markets and tighter stops in calmer markets.

Take Profit: Set at 3 times the ATR from the entry price. This ensures a favorable risk-reward ratio of 1:1.5, aiming for higher rewards on successful trades.

Visualization
SMAs: The 50-day and 200-day SMAs are plotted on the chart to visualize the trend direction.
MACD Crossovers: Bullish and bearish MACD crossovers are highlighted on the chart to identify potential entry points.

Summary
This strategy is designed to align multiple indicators to increase the probability of successful trades by confirming trends and momentum before entering a position. It systematically manages risk with ATR-based stop loss and take profit levels, ensuring that trades are exited based on market conditions rather than arbitrary points. The combination of trend indicators (SMAs) with momentum and volatility indicators (MACD, RSI, ATR) creates a robust approach to trading in various market environments.
Average True Range (ATR)Relative Strength Index (RSI)Simple Moving Average (SMA)

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