反转复活振荡指标组合策略


创建日期: 2023-11-02 16:43:41 最后修改: 2023-11-02 16:43:41
复制: 1 点击次数: 407
1
关注
1124
关注者

反转复活振荡指标组合策略

概述

该策略是一个组合策略,结合使用了反转策略和复活振荡指标策略,目的是获取更可靠的交易信号。

策略原理

该策略由两部分组成:

  1. 反转策略

    反转策略来自Ulf Jensen的《我如何在期货市场上将资金增加两倍》一书第183页。该策略属于反转类型,具体逻辑是:

    • 当收盘价比前一日收盘价高,连续两日时,并且9日慢速Stoch指标低于50时,做多入场。

    • 当收盘价比前一日收盘价低,连续两日时,并且9日快速Stoch指标高于50时,做空入场。

  2. 复活振荡指标策略

    复活振荡指标通过计算市场中最细微波动的差值,其值一般在-1到1之间波动。指标数值越高,表示趋势性越强,无论是涨趋势还是跌趋势。

    当指标达到较高值时,做多;当指标达到较低值时,做空。该指标适合用于日内交易。

最后,当两种策略信号同向时,即进行相关方向的交易。

优势分析

  • 结合反转策略和趋势策略,可以过滤掉一些假信号,提高交易信号的可靠性。

  • 反转策略可以捕捉到短期反转机会;复活振荡指标策略可以捕捉中长线趋势。

  • Stoch指标参数优化较好,可以有效过滤震荡市场的假信号。

  • 复活振荡指标对细微市场波动较为敏感,可以提前捕捉到趋势转折。

风险及解决方案

  • 反转策略容易被巨大趋势反转吞噬,可适当调整参数,或与趋势策略组合使用。

  • 指标策略容易产生过多交易信号,可适当调整参数,或与其他过滤指标组合使用。

  • 两种策略信号可能不一致产生冲突,可根据历史回测数据调整参数,优化两者配合。

  • 可引入止损策略,以控制单笔损失。

优化方向

  • 测试不同的反转参数组合,找到最佳参数。

  • 测试不同的复活振荡指标参数,找到最优参数。

  • 尝试不同的指标参数优化方法,如遗传算法、随机森林等。

  • 增加其他辅助指标,进一步过滤信号。

  • 增加机器学习模型,提高信号准确率。

  • 引入风险管理机制,如止损、仓位管理等。

总结

该策略通过组合反转策略和复活振荡指标策略,综合利用两种不同类型策略的优势,能够提高交易信号质量,在回测中表现出较好的效果。通过参数优化、增加其他指标、风险管理等进一步优化,该策略有望取得更好的实盘效果。总体来说,这是一个非常有创新思路的策略,值得进一步研究和应用。

策略源码
/*backtest
start: 2023-10-02 00:00:00
end: 2023-10-26 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 07/10/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 value of Fractal Chaos Oscillator is calculated as the difference between 
// the most subtle movements of the market. In general, its value moves between 
// -1.000 and 1.000. The higher the value of the Fractal Chaos Oscillator, the 
// more one can say that it follows a certain trend – an increase in prices trend, 
// or a decrease in prices trend.
//
//   Being an indicator expressed in a numeric value, traders say that this is an 
// indicator that puts a value on the trendiness of the markets. When the FCO reaches 
// a high value, they initiate the “buy” operation, contrarily when the FCO reaches a 
// low value, they signal the “sell” action. This is an excellent indicator to use in 
// intra-day trading.
//
// 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

fractalUp(pattern) =>
    p = high[pattern+1]
    okl = 1
    okr = 1
    res = 0.0
	for i = pattern to 1
		okl := iff(high[i] < high[i+1] and okl == 1 , 1, 0)
	for i = pattern+2 to pattern*2+1
		okr := iff(high[i] < high[i-1] and okr == 1, 1, 0)
	res := iff(okl == 1 and okr == 1, p, res[1])
    res

fractalDn(pattern) =>
    p = low[pattern+1]
    okl = 1
    okr = 1
    res = 0.0
	for i = pattern to 1
		okl := iff(low[i] > low[i+1] and okl == 1 , 1, 0)
	for i = pattern+2 to pattern*2+1
		okr := iff(low[i] > low[i-1] and okr == 1, 1, 0)
	res := iff(okl == 1 and okr == 1, p, res[1])
    res

FCO(Pattern) =>
    pos = 0.0
    xUpper = fractalUp(Pattern) 
    xLower = fractalDn(Pattern)
    xRes = iff(xUpper != xUpper[1], 1, 
             iff(xLower != xLower[1], -1, 0))
    pos := iff(xRes == 1, 1,
             iff(xRes == -1, -1, nz(pos[1], 0))) 
    pos

strategy(title="Combo Backtest 123 Reversal & Fractal Chaos Oscillator", shorttitle="Combo", overlay = true)
Length = input(15, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
Pattern = input(1, minval=1)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posFCO = FCO(Pattern)
pos = iff(posReversal123 == 1 and posFCO == 1 , 1,
	   iff(posReversal123 == -1 and posFCO == -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 )
更多内容