This strategy combines two different strategies. The first strategy generates signals based on the dual moving average crossover of stock prices. The second strategy is based on the Awesome Oscillator from the Williams Indicators. The final signal takes the intersection of the two strategy signals to form the final trading signal.
The first strategy generates a buy signal when yesterday’s close is higher than the previous day’s close and the fast 9-day Stochastic Oscillator is lower than the slow 3-day Stochastic Oscillator D-line. It generates a sell signal when yesterday’s close is lower than the previous day’s close and the fast Stochastic Oscillator is higher than the slow Stochastic Oscillator D-line.
The second strategy calculates the difference between the 5-day and 34-day price fluctuations and computes moving averages of that difference. When the current value is above the previous period, it is a buy signal. When the current value is below the previous period, it is a sell signal.
The two strategy signals are combined by taking their intersection. A long position is taken when both strategies give a buy signal. A short position is taken when both strategies give a sell signal.
This strategy combines the advantages of the dual moving average crossover strategy and the Williams Indicator strategy. The dual moving average crossover strategy can catch mid- to long-term trends. The Williams Indicator strategy can capture short-term trading opportunities. Combining the two strategies enables both profit-taking and prevention of false breakouts.
In addition, the use of multiple input parameters allows optimization for different stocks and market conditions, making the strategy adaptable to a wider range of market environments.
The biggest risk is that the signals from the two strategies may not be consistent. When one strategy generates a buy signal while the other generates a sell signal, the combined strategy cannot produce a meaningful signal, potentially missing trading opportunities.
In addition, the multiple parameters pose some difficulty for optimization. Unsuitable parameter combinations may lead to poor strategy performance.
To reduce risks, either strategy signal may be used exclusively. Also, suitable parameter ranges can be researched for different market conditions.
The strategy can be enhanced in several aspects:
Evaluate signal consistency between the two strategies under different parameter combinations to find the optimal parameters for signal matching.
Test performance across different products, timeframes to find the best application scope.
Consider replacing the dual moving average crossover with other technical indicators like KDJ to diversify the strategy combination.
Incorporate stop loss mechanisms to control risks, e.g. set maximum drawdown stops.
This strategy combines the dual moving average crossover strategy and the Williams Indicator strategy to capture both trend tracking and short-term signals. Through parameter optimization, it can adapt to a wide range of market conditions. However, inconsistent signal matching and complex parameter optimization remain its challenges. Overall, it provides an effective approach to quantitative trading and is worth further research and optimization to reduce risks and improve robustness.
/*backtest start: 2024-01-01 00:00:00 end: 2024-01-31 00:00:00 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=3 //////////////////////////////////////////////////////////// // Copyright by HPotter v1.0 20/06/2019 // This is combo strategies for get a cumulative signal. // // 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. // // Second strategy // This indicator plots the oscillator as a histogram where blue denotes // periods suited for buying and red . for selling. If the current value // of AO (Awesome Oscillator) is above previous, the period is considered // suited for buying and the period is marked blue. If the AO value is not // above previous, the period is considered suited for selling and the // indicator marks it as red. // You can make changes in the property for set calculating strategy MA, EMA, WMA // // 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 BillWilliamsAC(nLengthSlow, nLengthFast,nLengthMA, nLengthEMA, nLengthWMA, bShowWMA, bShowMA, bShowEMA) => pos = 0 xSMA1_hl2 = sma(hl2, nLengthFast) xSMA2_hl2 = sma(hl2, nLengthSlow) xSMA1_SMA2 = xSMA1_hl2 - xSMA2_hl2 xSMA_hl2 = sma(xSMA1_SMA2, nLengthFast) nRes = xSMA1_SMA2 - xSMA_hl2 xResWMA = wma(nRes, nLengthWMA) xResMA = sma(nRes, nLengthMA) xResEMA = ema(nRes, nLengthEMA) xSignalSeries = iff(bShowWMA, xResWMA, iff(bShowMA, xResMA, iff(bShowEMA, xResEMA, na))) cClr = nRes > nRes[1] ? blue : red pos := iff(xSignalSeries[2] < 0 and xSignalSeries[1] > 0, 1, iff(xSignalSeries[2] > 0 and xSignalSeries[1] < 0, -1, nz(pos[1], 0))) pos strategy(title="Combo Backtest 123 Reversal & Bill Williams. Awesome Oscillator (AC) with Signal Line", shorttitle="Combo", overlay = true) Length = input(14, minval=1) KSmoothing = input(1, minval=1) DLength = input(3, minval=1) Level = input(50, minval=1) //------------------------- nLengthSlow = input(34, minval=1, title="Length Slow") nLengthFast = input(5, minval=1, title="Length Fast") nLengthMA = input(15, minval=1, title="MA") nLengthEMA = input(15, minval=1, title="EMA") nLengthWMA = input(15, minval=1, title="WMA") bShowWMA = input(type=bool, defval=true, title="Show and trading WMA") bShowMA = input(type=bool, defval=false, title="Show and trading MA") bShowEMA = input(type=bool, defval=false, title="Show and trading EMA") reverse = input(false, title="Trade reverse") posReversal123 = Reversal123(Length, KSmoothing, DLength, Level) posBillWilliamsAC = BillWilliamsAC(nLengthSlow, nLengthFast,nLengthMA, nLengthEMA, nLengthWMA, bShowWMA, bShowMA, bShowEMA) pos = iff(posReversal123 == 1 and posBillWilliamsAC == 1 , 1, iff(posReversal123 == -1 and posBillWilliamsAC == -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 )template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6