本策略是一种组合策略,结合使用了三种不同的策略来产生交易信号。首先是123形态反转策略,它会在价格出现特定形态时产生交易信号;其次是均线交叉策略,它通过比较移动平均线和指数移动平均线的交叉来判断趋势;最后,本策略还允许选择是否进行反向交易。这三种策略的组合可以捕捉趋势反转点,同时过滤掉部分噪音交易信号。
该策略来源于Ulf Jensen的《我如何在期货市场上获得三倍收益》一书中提出的方法。该策略基于股票的收盘价和斯托克随机指标进行交易。具体规则是:
当收盘价比前一日收盘价高,且比前两日收盘价也高,同时9日周期的Stochastic Slow指标低于50时,做多;当收盘价比前一日收盘价低,且比前两日收盘价也低,同时9日周期的Stochastic Fast指标高于50时,做空。
这样,它可以在价格出现三日新高或新低的同时,结合随机指标的过卖或过买信号来捕捉反转机会。
该策略使用 lengthMA周期的简单移动平均线 和 lengthEMA周期的指数移动平均线的交叉来产生交易信号。规则是:
当指数移动平均线上穿简单移动平均线时做多;当指数移动平均线下穿简单移动平均线时做空。
这样,它可以比较直观地判断出价格趋势的转折点。且指数移动平均线对价格变化更为敏感,可以更早地发出交易信号。
本策略允许选择是否进行反向交易。如果选择反向交易,那么做多信号会变成做空,做空信号会变成做多。这对于一些坚信市场常存在误导性行为的交易者来说可能更有利。
这种组合策略结合多种单一策略的优点,可以在一定程度上规避单一策略的风险,提高收益率。
具体来说,123形态反转策略可以在价格出现转折迹象时及时捕捉;均线交叉策略可以判断趋势方向;允许反向交易可以减少被套利的概率。
总的来说,本策略反应灵敏,良好跟踪趋势,并可自定义配置以适应不同市场环境。
本策略最大的风险在于组合策略本身就比较复杂,不太容易判断 Fail/Success 的原因,不利于进行策略优化。
此外,跟其他任何技术分析策略一样,本策略也面临被套、止损失效等问题。具体来说,价格剧烈震荡时,容易产生误信号;持续、剧烈的趋势时,止损线易被突破。
为降低这些风险,可以适当调整参数,使指标更为平稳;可以适当放宽止损线,或使用交易量止损等方法。
本策略还可从以下几个方面进行优化:
添加过滤条件,如交易量、波动率等指标,可过滤掉一些无效信号
优化参数,寻找最佳的参数组合
尝试不同的均线交叉指标,寻找更匹配当下市场环境的指标
增加机器学习模型,利用AI技术自动优化参数
本策略作为一种组合策略,集多种单一策略优点于一身,可以有效跟踪趋势反转,适合中长线操作。配以参数优化、风险控制等手段,其效果可获得显著提高。值得量化交易从业者深入研究、应用与改进。
/*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 )