All indicators

CCI and MACD Auto Trading Strategy with Risk/Reward

Jun 27, 2024

Static chart image
SignalsOscillatorsMoney ManagementMoving Averages

The CCI and MACD Auto Trading Strategy with Risk/Reward tool automates trend-following trading decisions by combining momentum and trend-reversal signals with dynamic risk management.

Usage

The strategy generates trading signals based on the confluence of the Commodity Channel Index (CCI) and the Moving Average Convergence Divergence (MACD) histogram.

  • Long Entry: Occurs when the MACD histogram is above zero (indicating positive momentum) and the CCI crosses above the -100 level (signaling an exit from an oversold region).
  • Short Entry: Occurs when the MACD histogram is below zero (indicating negative momentum) and the CCI crosses below the +100 level (signaling an exit from an overbought region).

Once a trade is entered, the script automatically calculates exit levels based on market structure. For long trades, the stop-loss is placed at the recent low of the lookback period, while for short trades, it is placed at the recent high. The take-profit is then set at a fixed 1:1.5 risk/reward ratio relative to the entry price and stop-loss distance.

Details

This strategy aims to filter out noise by requiring both momentum and reversal conditions to be met simultaneously. By using the CCI as a timing mechanism and the MACD as a trend filter, it attempts to capture moves at the start of a trend shift.

The integration of dynamic risk management ensures that trade exits are not arbitrary but are instead grounded in recent price action. This method of utilizing local extremes for stop placement helps the strategy adapt to varying market volatility, maintaining a consistent risk/reward profile across different market conditions.

Settings

CCI

  • CCI Length: Sets the lookback period for the Commodity Channel Index calculation.
  • CCI Source: Determines the price data used for the CCI calculation (default is HLC3).

MACD

  • MACD Fast Length: The period for the fast moving average.
  • MACD Slow Length: The period for the slow moving average.
  • MACD Source: The price source for MACD calculations (default is Close).
  • MACD Signal Smoothing: The period for the signal line smoothing.
  • MACD Oscillator MA Type: Choice between SMA or EMA for the MACD oscillator calculation.
  • MACD Signal Line MA Type: Choice between SMA or EMA for the signal line calculation.

Strategy & Visuals

  • Lookback Period: Defines the number of bars used to determine the recent high and low for stop-loss placement.
  • Show CCI: Toggles the visibility of the CCI line.
  • Show MACD: Toggles the visibility of the MACD oscillator.
  • Show Recent Low/High: Displays the price levels used for stop-loss calculations on the chart.

FAQ

How do I access this script?

You can get access on the LuxAlgo Library for charting platforms like TradingView, MetaTrader (MT4/MT5), and NinjaTrader for free.

Can I change the risk/reward ratio?

In the current version, the risk/reward ratio is hardcoded to 1:1.5 to maintain a balanced profile, but the stop-loss distance varies based on the "Lookback Period" setting.

Which timeframes work best for this strategy?

While the script can be applied to any timeframe, it is generally more effective on timeframes where trends are more established, such as the 1-hour or 4-hour charts, to reduce whipsaws in the MACD histogram.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

Unlock the entire LuxAlgo Library

Every indicator, every strategy, full charts, and complete access to Quant — our AI agent.