The MACDStrategy is a trading strategy that uses two technical indicators, MACD (Moving Average Convergence Divergence) and CCI (Commodity Channel Index), to identify uptrends and downtrends in the market. In this strategy, an uptrend is defined as follows:
MACD value is above the MACD signal value
CCI value is less than -50
A downtrend is defined as follows:
MACD value is below the MACD signal value
CCI value is greater than 100
The strategy aims to optimize the CCI value within specific ranges for buying and selling. The buy side CCI value is optimized between -700 and 0, while the sell side CCI value is optimized between 0 and 700.
The strategy sets predefined values for minimal ROI (Return on Investment) and stop loss.
The minimal ROI values are set for different timeframes (60, 30, 20, and 0 minutes).
The stop loss is set at -0.3. The timeframe used for this strategy is 5 minutes. The strategy populates various indicators, including MACD, MACD signal, MACD histogram, and CCI, using historical market data. The populate_buy_trend function determines the buy signal based on the strategy's conditions. A buy signal is generated when:
MACD value is greater than MACD signal value
CCI value is less than or equal to the buy_cci parameter value
Volume is greater than 0
The populate_sell_trend function determines the sell signal based on the strategy's conditions. A sell signal is generated when:
MACD value is less than MACD signal value
CCI value is greater than or equal to the sell_cci parameter value
Volume is greater than 0
By backtesting this strategy on historical data, users can evaluate its performance and make informed trading decisions.