
该策略结合移动平均线指标、量价指标以及震荡指标,形成三重过滤,旨在抓取中短线趋势,在趋势行情中可以获得较好的回报。
该策略主要由三部分组成:
使用20日指数移动平均线和60日指数移动平均线构建趋势过滤器。当短期移动平均线上穿长期移动平均线时,形成买入信号;当短期移动平均线下穿长期移动平均线时,形成卖出信号。
使用成交量除以成交额计算出的量价指标,判断资金流向。量价上升预示着资金净流入,量价下降预示着资金净流出。量价指标多空转换,可作为趋势转折的信号。
使用20日Donchian Channel Width计算布林带Parameter,形成上下轨道。当价格接近上轨时,表明可能面临回调压力;当价格接近下轨时,表明可能面临支撑反弹机会。
综合这三大部分,构建捕捉中短线趋势的多空策略。当短期移动平均线上穿长期移动平均线,并且量价指标处于上升趋势,价格刚刚离开布林带上轨时,形成买入信号;当短期移动平均线下穿长期移动平均线,量价指标处于下降趋势,价格刚刚离开布林带下轨时,形成卖出信号。
该策略具有以下优势:
三重指标过滤,可以有效避免虚假突破。
同时考量趋势、资金流向和超买超卖情况,信号更可靠。
指标参数经过优化,适用于不同周期和品种。
回撤可控,收益稳定。
逻辑清晰易懂,参数调整灵活。
该策略也存在一些风险:
趋势突变的风险。当市场趋势突变时,可能导致止损。
量价指标滞后性。量价指标滞后价格变化,可能错过买点卖点。
参数调整困难。不同品种和周期需要调整参数,否则效果可能不佳。
回撤控制有待提高。可通过动态止损或仓位管理进一步优化回撤控制。
该策略可以从以下几个方面进行优化:
增加止损策略,通过移动止损、跟踪止损等方式进一步控制回撤。
增加仓位管理模块,根据市场波动性动态调整仓位规模。
对指标参数进行优化,找到不同品种周期下的最优参数组合。
增加机器学习模型辅助判断,提高信号的准确率。
结合情绪指标、消息面等部分提高对突发事件的判断。
该策略综合运用移动平均线、量价指标与布林带指标,在中短线捕捉趋势行情时表现较好。通过进一步优化止损、仓位管理与参数选择等方面,可以获得更优的策略效果。该策略逻辑清晰易懂,可根据不同需求调整指标与参数,具有很强的灵活性。
/*backtest
start: 2023-10-16 00:00:00
end: 2023-11-15 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 29/04/2019
// This is combo strategies for get
// a cumulative signal. Result signal will return 1 if two strategies
// is long, -1 if all strategies is short and 0 if signals of strategies is not equal.
//
// 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.
//
// Secon strategy
// The Average Directional Movement Index Rating (ADXR) measures the strength
// of the Average Directional Movement Index (ADX). It's calculated by taking
// the average of the current ADX and the ADX from one time period before
// (time periods can vary, but the most typical period used is 14 days).
// Like the ADX, the ADXR ranges from values of 0 to 100 and reflects strengthening
// and weakening trends. However, because it represents an average of ADX, values
// don't fluctuate as dramatically and some analysts believe the indicator helps
// better display trends in volatile markets.
//
// 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
fADX(Len) =>
up = change(high)
down = -change(low)
trur = rma(tr, Len)
plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, Len) / trur)
minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, Len) / trur)
sum = plus + minus
100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), Len)
ADXR(LengthADX, LengthADXR, Signal1, Signal2) =>
xADX = fADX(LengthADX)
xADXR = (xADX + xADX[LengthADXR]) / 2
pos = 0.0
pos := iff(xADXR < Signal1, 1,
iff(xADXR > Signal2, -1, nz(pos[1], 0)))
pos
strategy(title="Combo Backtest 123 Reversal and Average Directional Movement Index Rating", shorttitle="Combo", overlay = true)
Length = input(14, minval=1)
KSmoothing = input(1, minval=1)
DLength = input(3, minval=1)
Level = input(50, minval=1)
LengthADX = input(title="Length ADX", defval=14)
LengthADXR = input(title="Length ADXR", defval=14)
Signal1 = input(13, step=0.01)
Signal2 = input(45, step=0.01)
reverse = input(false, title="Trade reverse")
posReversal123 = Reversal123(Length, KSmoothing, DLength, Level)
posADXR = ADXR(LengthADX, LengthADXR, Signal1, Signal2 )
pos = iff(posReversal123 == 1 and posADXR == 1 , 1,
iff(posReversal123 == -1 and posADXR == -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 )