This strategy is a combination strategy that combines three different strategies to generate trading signals. First, it uses the 123 reversal pattern strategy, which generates trading signals when prices form specific patterns. Second, it uses the moving average crossover strategy, which judges the trend by comparing the crossovers between moving averages and exponential moving averages. Finally, this strategy also allows choosing whether to trade reversely. The combination of these three strategies can capture trend reversal points while filtering out some noisy trading signals.
This strategy originates from the method proposed in Ulf Jensen’s book “How I Tripled My Money in the Futures Market”. The strategy trades based on the closing price of stocks and the Stochastic Oscillator indicator. Specifically, the rules are:
When the closing price is higher than the previous closing price and also higher than the closing price two days ago, while the 9-period Stochastic Slow is below 50, go long. When the closing price is lower than the previous closing price and also lower than the closing price two days ago, while the 9-period Stochastic Fast is above 50, go short.
Thus, it can capture reversal opportunities when prices form three-day new highs or lows while combining with oversold or overbought signals from the stochastic indicator.
This strategy uses the crossover between the lengthMA-period simple moving average and the lengthEMA-period exponential moving average to generate trading signals. The rules are:
When the exponential moving average crosses above the simple moving average, go long. When the exponential moving average crosses below the simple moving average, go short.
Thus, it can intuitively judge the turning points of price trends. Also, the exponential moving average is more sensitive to price changes and can issue trading signals earlier.
This strategy allows choosing whether to trade reversely. If reverse trading is selected, long signals become short signals, and vice versa. This may be more beneficial for some traders who firmly believe there are often misleading behaviors in the market.
This combined strategy inherits the advantages of various single strategies to some extent, which can mitigate the risks of a single strategy and increase returns.
Specifically, the 123 reversal pattern strategy can timely capture turns when prices show signs of reversal; the moving average crossover strategy can determine the trend direction; allowing reverse trading can reduce the probability of being trapping.
In general, this strategy is sensitive, tracks trends well, and can be custom configured to suit different market environments.
The most significant risk of this strategy is that the combination strategy itself is quite complicated, making it hard to determine the reasons for failure/success and unfavorable for strategy optimization.
Besides, like any other technical analysis strategy, this strategy also faces risks like being trapped and stop-loss failure. Specifically, it is prone to generate false signals when prices fluctuate sharply. Also, stop-loss lines tend to be broken in a persistent and violent trend.
To mitigate these risks, we can appropriately adjust parameters to make indicators more stable, loosen stop-loss lines reasonably, or use methods like volume stop-loss.
This strategy can be further optimized in the following aspects:
Add filtering conditions like trading volumes and volatility to filter out invalid signals.
Optimize parameters to find the best parameter combinations.
Try different moving average crossover indicators to find the ones that match the current market best.
Increase machine learning models to automatically optimize parameters using AI technologies.
As a combination strategy, this strategy combines the advantages of various single strategies and can effectively track trend reversals. It is suitable for medium-to-long-term operations. With proper optimization, risk management, etc., its performance can be significantly improved. It deserves in-depth research, application, and improvement by practitioners of quantitative trading.
/*backtest start: 2023-12-27 00:00:00 end: 2024-01-03 00:00:00 period: 3m basePeriod: 1m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 //////////////////////////////////////////////////////////// // Copyright by HPotter v1.0 19/06/2020 // 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 // The Moving Average Crossover trading strategy is possibly the most popular // trading strategy in the world of trading. First of them were written in the // middle of XX century, when commodities trading strategies became popular. // This strategy is a good example of so-called traditional strategies. // Traditional strategies are always long or short. That means they are never // out of the market. The concept of having a strategy that is always long or // short may be scary, particularly in today’s market where you don’t know what // is going to happen as far as risk on any one market. But a lot of traders // believe that the concept is still valid, especially for those of traders who // do their own research or their own discretionary trading. // This version uses crossover of moving average and its exponential moving average. // // 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 MACross(LengthMA,LengthEMA) => pos = 0 xMA = sma(close, LengthMA) xEMA = ema(xMA, LengthEMA) pos := iff(xEMA < xMA , 1, iff(xEMA > xMA, -1, nz(pos[1], 0))) pos strategy(title="Combo Backtest 123 Reversal & EMA & MA Crossover", shorttitle="Combo", overlay = true) Length = input(14, minval=1) KSmoothing = input(1, minval=1) DLength = input(3, minval=1) Level = input(50, minval=1) //------------------------- LengthMA = input(10, minval=1) LengthEMA = input(10,minval=1) reverse = input(false, title="Trade reverse") posReversal123 = Reversal123(Length, KSmoothing, DLength, Level) posMACross = MACross(LengthMA,LengthEMA) pos = iff(posReversal123 == 1 and posMACross == 1 , 1, iff(posReversal123 == -1 and posMACross == -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 ? #b50404: possig == 1 ? #079605 : #0536b3 )template: strategy.tpl:40:21: executing "strategy.tpl" at <.api.GetStrategyListByName>: wrong number of args for GetStrategyListByName: want 7 got 6