本策略综合运用反转策略与布林带强势策略,形成组合交易信号,实现趋势跟踪与反转捕捉的双重功能。
根据丘晨的《我如何在期货市场上盈利三倍》一书中第183页的反转策略逻辑:当收盘价连续2天高于前一天的收盘价,而9日随机指标的慢速线低于50时,做多;当收盘价连续2天低于前一天的收盘价,而9日随机指标的快速线高于50时,做空。
根据亚历山大·艾尔德博士的布林带强势指标:使用13日指数移动平均线表示市场价值共识,多头强势指标反映买方驱动价格高于价值共识的能力,空头强势指标反映卖方驱动价格低于价值共识的能力。多头强势指标计算为当日最高价减去13日指数移动平均线,空头强势指标为当日最低价减去13日指数移动平均线。
本策略将强势指标的阈值设定为0,即只要强势指标>0就产生交易信号。
当反转策略和强势策略的交易信号一致时,产生最终的交易信号。做多信号为反转信号看多与强势信号看多的综合;做空信号为反转信号看空与强势信号看空的综合。
这是一个综合型策略,通过同时使用反转策略和趋势跟踪策略形成交易信号,兼具抓反弹和跟踪趋势的优势。
反转部分可以锁定跳空缺口后的反转机会。强势部分则可确保仅在趋势存在时打开头寸。两者结合,可有效过滤假突破,避免被套。
参数优化弹性较大,可针对不同品种和周期进行调整寻找最佳参数组合。
反转策略与强势策略同时看多或看空的概率较低,信号产生频率可能不高,存在一定程度的信号稀疏风险。
反转部分可能误判盘中震荡调整为反转机会,从而过早建仓。强势部分则可能错失部分反转机会。两者结合使用可以在一定程度上缓解这些风险。后期可考虑引入��세判断模块,进一步优化。
本策略既含有趋势追踪,也兼具反转交易的特性,可谓是综合型策略中的佼佼者。通过参数优化,可期望获得良好的稳定收益。同时也需要注意防范信号稀疏和误判的风险,后期可从引入趋势判断和止损模块等方面进行优化,使策略的实战性能更加出色。
/*backtest
start: 2023-10-21 00:00:00
end: 2023-11-20 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 15/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
// Developed by Dr Alexander Elder, the Elder-ray indicator measures buying
// and selling pressure in the market. The Elder-ray is often used as part
// of the Triple Screen trading system but may also be used on its own.
// Dr Elder uses a 13-day exponential moving average (EMA) to indicate the
// market consensus of value. Bull Power measures the ability of buyers to
// drive prices above the consensus of value. Bear Power reflects the ability
// of sellers to drive prices below the average consensus of value.
// Bull Power is calculated by subtracting the 13-day EMA from the day's High.
// Bear power subtracts the 13-day EMA from the day's Low.
// You can use in the xPrice any series: Open, High, Low, Close, HL2, HLC3, OHLC4 and ect...
//
// 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
BP(Trigger,Length) =>
pos = 0
DayHigh = 0.0
xPrice = close
xMA = ema(xPrice,Length)
DayHigh := iff(dayofmonth != dayofmonth[1], high, max(high, nz(DayHigh[1])))
nRes = DayHigh - xMA
pos := iff(nRes > Trigger, 1,
iff(nRes < Trigger, -1, nz(pos[1], 0)))
pos
strategy(title="Combo Strategy 123 Reversal & Elder Ray (Bull Power)", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
//-------------------------
LengthBP = input(13, minval=1)
Trigger = input(0)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posBP = BP(Trigger,LengthBP)
pos = iff(posReversal123 == 1 and posBP == 1 , 1,
iff(posReversal123 == -1 and posBP == -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 )