Type/to search

Trend Following Strategy Based on QQE and MA

Common strategy
Created: 2023-12-29 16:36:47
Last modified: 3 years ago
1
Follow
1802
Followers

img

Overview

This is a trend following strategy based on the QQE (Qualitative Quantitative Estimation) indicator and moving averages. It determines the trend direction and generates trading signals based on fast QQE crosses filtered by the direction of moving averages.

The strategy can use three kinds of QQE crosses to determine the trading signal: (1) Smooth RSI crossing 0 line; (2) Smooth RSI crossing fast QQE line; (3) Smooth RSI exiting the RSI threshold channel. By default it uses the third cross to open position and the second cross to close position.

The buy and sell signals can choose to add an additional filter by moving averages: the close price should be above (below) the fast MA line, and the fast MA line should be above (below) the slow MA line, to generate a trading signal.

This strategy is suitable to be used in automated trading with signal-to-signal mode.

Principle

The core indicator of this strategy is QQE. Its calculation formula is as below:

Wilders_Period = RSILen * 2 - 1 Rsi = rsi(close,RSILen) RSIndex = ema(Rsi, SF) AtrRsi = abs(RSIndex - RSIndex[1]) MaAtrRsi = ema(AtrRsi, Wilders_Period) DeltaFastAtrRsi = ema(MaAtrRsi,Wilders_Period) * QQEfactor newshortband = RSIndex + DeltaFastAtrRsi newlongband = RSIndex - DeltaFastAtrRsi

Where RSILen is the length period of RSI, and SF is the RSI smoothing factor. QQE is essentially a smoothed RSI. It calculates an upper and lower channel based on a fast ATR, and the crossing of price over the channel indicates buy or sell signals.

The strategy uses three kinds of QQE crosses to identify trading signals:

  1. Smooth RSI crossing 0 line (XZ)
QQEzlong = RSIndex >= 50 ? QQEzlong + 1 : 0 QQEzshort = RSIndex < 50 ? QQEzshort + 1 : 0
  1. Smooth RSI crossing fast QQE line (XQ), like an early swing signal
QQExlong = FastAtrRsiTL < RSIndex ? QQExlong + 1 : 0 QQExshort = FastAtrRsiTL > RSIndex ? QQExshort + 1 : 0
  1. Smooth RSI exiting threshold channel (XC), like a confirmed swing signal
threshhold = 10 QQEclong = RSIndex > (50 + threshhold) ? QQEclong + 1 : 0 QQEcshort = RSIndex < (50 - threshhold) ? QQEcshort + 1 : 0

One or multiple of the above three crosses can be selected to identify entry and exit signals.

The buy and sell signals can choose to add an additional filter by moving averages:

// Filter condition QQEflong = close > ma_medium AND ma_medium > ma_slow AND ma_fast > ma_medium QQEfshort = close < ma_medium AND ma_medium < ma_slow AND ma_fast < ma_medium

This helps avoid false signals in sideways markets.

The strategy is suitable for automated trading by using different QQE crosses for entries and exits:

Entry signal = XC OR XQ OR XZ Exit signal = XQ OR XZ

Advantages

The advantages of this strategy include:

  1. Using the QQE indicator to determine trend and cross signals. QQE itself has the characteristic of smoothing and noise reduction, which can decrease false signals.

  2. Adding filter by moving averages can further avoid false signals in sideways markets and improve signal quality.

  3. Choosing different QQE crosses for entry and exit enables automated trading.

  4. The smooth RSI signal has lagging effect, so the buy/sell signals will not repaint.

  5. The parameters can be optimized on different timeframes to find the best combination.

Risks

There are also some risks of this strategy:

  1. Wrong signals may occur during trend reversal. Stop loss should be set to control risks.

  2. Inappropriate parameter settings can affect strategy performance. Multiple tests and optimizations are needed to find the best parameters.

  3. Different symbols and timeframes need separate test and parameter tuning.

  4. Mechanical trading has risks of drawdown and consecutive losses. Position sizing and risk management are necessary.

The corresponding solutions are:

  1. Set stop loss to exit positions when loss reaches a certain amount.

  2. Test different parameter combinations thoroughly to find the optimal parameters.

  3. Adjust parameters according to symbol and timeframe characteristics.

  4. Use proper capital management, scale-in positions, and control per trade position size.

Optimization Directions

There are several directions that this strategy can be optimized:

  1. Optimize QQE parameters including RSI length, RSI smoothing length, fast ATR length etc, to find the optimal parameter combination.

  2. Optimize moving average parameters, adjust period, type etc to match best with QQE indicator.

  3. Test different QQE crosses for entry and exit to find the most stable combination.

  4. Fine tune parameters according to different symbols and timeframes. Use shorter periods for lower timeframes and intraday trading.

  5. Add stop loss mechanism to stop out when loss reaches certain percentage.

  6. Appropriately reduce position sizing and test different position management methods.

Conclusion

This strategy integrates using the QQE indicator for judging trend and crosses, and the moving average for filter, to generate trading signals. During live trading it can be optimized by adjusting parameters to improve signal quality, and by strict money management to control risks. The strategy suits automated trading with signal-to-signal mode, and can also aid discretionary trading. Further optimizations on logics and parameters can make it adaptable to more market conditions.

Source
Pine
/*backtest
start: 2022-12-22 00:00:00
end: 2023-12-28 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
//

//*** START of COMMENT OUT [Alerts]
Strategy parameters
Strategy parameters
Relative TimeFrame Multiplier for Second MA Ribbon (0=none, max=100)
Show Moving Average Lines
Fast MA Type:
Fast - Length
Medium MA Type:
Medium - Length
Slow MA Type:
Slow Length
RSI Length
RSI Smoothing Factor
Fast QQE Factor
RSI Threshhold
Show QQE Signal crosses
Show QQE Zero crosses
Show QQE Thresh Hold Channel Exits
Select which QQE signal to Buy/Sell
Select which QQE signal to Close Order
Filter XQ Buy/Sell Orders by Threshold
Use Moving Average Filter
Use Trend Directional Filter
Only Alert First Buy/Sell in a new Trend
Source
Backtest Start Year
Backtest Start Month
Backtest Start Day
Comment
All comments (0)
No data
No data
  • 1
Forums
PINE Language
Get the app
iPhone Download
© 2015 - ∞ INVENTOR PTE LTD (SG)