Type/to search

Ergotic Dual-rail Reverse MACD Quantitative Trading Strategy

Common strategy
Created: 2023-12-21 11:07:51
Last modified: 3 years ago
1
Follow
1802
Followers

img

Overview

This strategy is a dual-rail reverse MACD quantitative trading strategy. It draws on the technical indicators described by William Blau in his book "Momentum, Direction and Divergence" and expands on them. The strategy also has backtesting capabilities and can incorporate additional features like alerts, filters, trailing stop loss, etc.

Principles

The core indicator of this strategy is MACD. It calculates the fast moving average EMA(r) and slow moving average EMA(slowMALen), then computes their difference xmacd. It also calculates the EMA(signalLength) of xmacd to get xMA_MACD. A long signal triggers when xmacd crosses above xMA_MACD, and a short signal triggers on a cross below. The key aspect of this strategy is the reverse trading signals, i.e. the relationship between xmacd and xMA_MACD is opposite to that of the conventional MACD indicator, which is also where the name "Reverse MACD" comes from.

In addition, the strategy incorporates trend filters. When a long signal fires, if the bullish trend filter is configured, it will check if the price is increasing. Similarly, the short signal checks for a downward price trend. RSI and MFI indicators can also be used to filter out signals. A stop loss mechanism is included to prevent losses beyond a threshold.

Advantage Analysis

The biggest advantage of this strategy is the powerful backtesting capabilities. You can choose different trading instruments, set the backtest timeframe, and optimize the strategy parameters based on specific instrument data. Compared to a simple MACD strategy, it incorporates trend and overbought/oversold analysis to filter out some identical signals. The dual-rail reverse MACD is different from the traditional MACD, allowing it to capitalize on some opportunities that the traditional MACD may miss.

Risk Analysis

The primary risk of this strategy comes from the reverse trading logic. While reverse signals can capture some opportunities missed by traditional signals, it also means forfeiting some conventional MACD entry points, necessitating careful assessment. Moreover, the MACD itself is prone to generating false bullish signals. The strategy may result in excessive trades and increased costs during choppy, directionless markets.

To mitigate risks, parameters can be optimized - tuning the moving average lengths; combining trends and indicator filters avoids signals in choppy markets; raising stop loss distances ensures capped losses on individual trades.

Optimization Directions

The strategy can be improved in several aspects:

  1. Adjust fast and slow rail parameters, optimize moving average lengths, backtest to find optimal parameter sets for specific instruments
  2. Add or tune trend filters, judge from backtest results whether it improves return
  3. Test different stop loss mechanisms, fixed or trailing, to determine the better performer
  4. Try combining other indicators like KD, Bollinger Bands to set additional filter conditions and ensure signal quality

Summary

The dual-rail reverse MACD quantitative strategy builds upon the classic MACD indicator with extensions and improvements. With flexible parameter configurations, abundant filter choices, and powerful backtesting functionality, it can be tuned to suit different trading instruments. Hence it is an intriguing and promising quantitative trading strategy worthy of further exploration.

Source
Pine
/*backtest
start: 2023-11-20 00:00:00
end: 2023-12-20 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version = 3
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 09/12/2016
// This is one of the techniques described by William Blau in his book
Strategy parameters
Strategy parameters
source
strategyType
From Month
From Day
From Year
To Month
To Day
To Year
R (32,55,89,100,144,200)
slowMALen
signalLength
Trade reverse (long/short switch)
Long only if price has increased
Short only if price has decreased
trending_price_length
trending_price_with_ema
trending_price_ema
rsi_length
RSI Sell Cutoff (Sell only if >= #)
RSI Buy Cutoff (Buy only if <= #)
Long only if RSI has increased
trending_rsi_length
mfi_length
mfi_lower
mfi_upper
Long only if MFI has increased
trending_mfi_length
TSL source
Use different timeframe for stop trigger? Uncheck box above.
tslTrigger
tslStop
Stop Loss %
Take Profit %
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)