Doubly Confident Price Oscillation Quant Strategy

Author: ChaoZhang, Date: 2024-02-18 10:10:16
Tags:

img

Overview

The main idea of this strategy is to combine the 123 Reversal strategy and the Absolute Price Oscillator indicator to obtain an integrated signal. Specifically, if both sub-strategies emit long signals, the final strategy signal is 1 (long); if both emit short signals, the final signal is -1 (short); if the signals are inconsistent, the final signal is 0 (no operation).

Principles

Firstly, the principle of the 123 Reversal strategy is: if the close price is lower than the previous day’s close for two consecutive days, and the Stochastic Oscillator is below the overbought line, go long; if the close price is higher than the previous day’s close for two consecutive days, and the Stochastic Oscillator is above the oversold line, go short.

Secondly, the Absolute Price Oscillator displays the difference between two exponential moving averages. A positive value indicates an upward trend, while a negative value indicates a downward trend.

Finally, this strategy combines the signals of the two sub-strategies, i.e. follow the signal if they are consistent; otherwise, do not operate.

Advantage Analysis

This strategy comprehensively considers short-term reversal signals and medium-to-long term trend signals, which can effectively identify turning points. Compared to using 123 Reversals or APO alone, this strategy can greatly improve the reliability of signals and reduce erroneous signals.

In addition, this strategy employs multiple technical indicators to judge the market comprehensively instead of relying on any single one. This avoids wrong judgments due to failure of one indicator.

Risk Analysis

The biggest risk is when the 123 Reversal and APO emit conflicting signals. In such cases, the operator needs to judge based on experience which signal is more reliable. Wrong judgements may lead to missing trading opportunities or losses.

In addition, drastic market changes may invalidate signals from both sub-strategies simultaneously. Traders need to monitor events that significantly impact markets, and pause the strategy if necessary.

Optimization

Possible optimization directions:

  1. Optimize sub-strategy parameters for more reliable signals, e.g. moving average periods.

  2. Add other auxiliary indicators to form a voting mechanism. Consistent signals from multiple indicators are more reliable.

  3. Add stop loss strategies. Timely stop loss on adverse price moves avoids further losses.

  4. Optimize entry and stop loss levels based on historical backtesting.

Conclusion

This strategy combines multiple technical indicators to judge the market, avoiding single indicator dependency risks to some extent and improving signal accuracy. There is also room for optimization based on investor requirements. Overall, the Doubly Confident Price Oscillation Quant Strategy provides reliable trade signals and is worth researching further.


/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=3
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 22/04/2019
// This is combo strategies for get 
// a cumulative signal. Result signal will return 1 if two strategies 
// is long, -1 if all strategies is short and 0 if signals of strategies is not equal.
//
// First strategy
// This System was created from the Book "How I Tripled My Money In The 
// Futures Market" by Ulf Jensen, Page 183. This is reverse type of strategies.
// The strategy buys at market, if close price is higher than the previous close 
// during 2 days and the meaning of 9-days Stochastic Slow Oscillator is lower than 50. 
// The strategy sells at market, if close price is lower than the previous close price 
// during 2 days and the meaning of 9-days Stochastic Fast Oscillator is higher than 50.
//
// Secon strategy
// The Absolute Price Oscillator displays the difference between two exponential 
// moving averages of a security's price and is expressed as an absolute value.
// How this indicator works
//    APO crossing above zero is considered bullish, while crossing below zero is bearish.
//    A positive indicator value indicates an upward movement, while negative readings 
//      signal a downward trend.
//    Divergences form when a new high or low in price is not confirmed by the Absolute Price 
//      Oscillator (APO). A bullish divergence forms when price make a lower low, but the APO 
//      forms a higher low. This indicates less downward momentum that could foreshadow a bullish 
//      reversal. A bearish divergence forms when price makes a higher high, but the APO forms a 
//      lower high. This shows less upward momentum that could foreshadow a bearish reversal.
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
Reversal123(Length, KSmoothing, DLength, Level) =>
    vFast = sma(stoch(close, high, low, Length), KSmoothing) 
    vSlow = sma(vFast, DLength)
    pos = 0.0
    pos := iff(close[2] < close[1] and close > close[1] and vFast < vSlow and vFast > Level, 1,
	         iff(close[2] > close[1] and close < close[1] and vFast > vSlow and vFast < Level, -1, nz(pos[1], 0))) 
	pos

AbsolutePriceOscillator(LengthShortEMA, LengthLongEMA) =>
    xPrice = close
    xShortEMA = ema(xPrice, LengthShortEMA)
    xLongEMA = ema(xPrice, LengthLongEMA)
    xAPO = xShortEMA - xLongEMA
    pos = 0.0    
    pos := iff(xAPO > 0, 1,
           iff(xAPO < 0, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal and Absolute Price Oscillator (APO)", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
LengthShortEMA = input(10, minval=1)
LengthLongEMA = input(20, minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posAbsolutePriceOscillator = AbsolutePriceOscillator(LengthShortEMA, LengthLongEMA)
pos = iff(posReversal123 == 1 and posAbsolutePriceOscillator == 1 , 1,
	   iff(posReversal123 == -1 and posAbsolutePriceOscillator == -1, -1, 0)) 
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1, 1, pos))	   
if (possig == 1) 
    strategy.entry("Long", strategy.long)
if (possig == -1)
    strategy.entry("Short", strategy.short)	 
if (possig == 0) 
    strategy.close_all()
barcolor(possig == -1 ? red: possig == 1 ? green : blue ) 

More