多时间框架随机指数均线策略(MTF Stochastic Strategy)是一个基于随机指数指标的量化交易策略。它同时利用当前时间框架和更高时间框架的随机指数均线,实现趋势跟踪和趋势反转的组合交易。
该策略的核心指标是随机指数K线和D线。K线反映最近的价格动量,D线是K线的移动平均线。它们的相对位置和方向可以判断价格趋势和可能的反转。
具体来说,当短期K线从下向上突破中期D线时,表示价格短期内存在向上突破的动量;当短期K线从上向下跌破中期D线时,表示价格短期内存在向下跌破的压力。
本策略采用两个时间框架的随机指数指标实现交易信号的确认与滤波。更高时间框架的随机指数指标用于确认趋势方向,当前时间框架的随机指数指标则用于发现短期突破点位实现交易切入。
当更高时间框架的随机指标确认处于上升趋势时,并且当前时间框架的随机指标显示价格存在向上突破时,做多;当更高时间框架的随机指标确认下降趋势,并且当前时间框架的随机指标显示价格存在向下跌破时,做空。
该策略结合多时间框架指标和当前突破,能够有效过滤市场噪音,锁定较高概率的获利交易。具体优势如下:
该策略也存在一些风险,主要体现在如下几个方面:
该策略的主要优化方向包括:
多时间框架随机指数均线策略是一种典型的趋势跟踪策略。它同时利用两种时间尺度下的随机指数指标实现对行情的精确把握。通过参数优化,可以进一步增强策略的稳定性和盈利能力。
/*backtest
start: 2023-02-22 00:00:00
end: 2024-02-28 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=3
strategy("MTF stochastic strategy", overlay=false,pyramiding=3,default_qty_type=strategy.percent_of_equity,default_qty_value=100,currency=currency.USD)
//
//this strategy is inspired to bobby thread in forexfactory forum
//
len = input(11, minval=1, title="Length for Main Stochastic")
smoothK = input(3, minval=1, title="SmoothK for Main Stochastic")
smoothD = input(3, minval=1, title="SmoothD for Main Stochastic")
upLine = input(80, minval=50, maxval=90, title="Upper Line Value?")
lowLine = input(20, minval=10, maxval=50, title="Lower Line Value?")
trailStep=input(50,minval=10,title="Trialing step value")
// current stochastic calculation
k = sma(stoch(close, high, low, len), smoothK)
d = sma(k, smoothD)
//mtf stochastic calculation smoothed with period
mtfK= sma(stoch(close, high, low, len), smoothK*3)
mtfD= sma(k, smoothD*3)
plot(k,"current TF k",black,style=linebr)
plot(d,"current TF d",gray,style=linebr)
plot(mtfK,"MTF TF k",red,style=line)
plot(mtfD,"Multi TF d",green,style=line)
hline(upLine)
hline(50)
hline(lowLine)
longCondition = crossover(mtfK, 50) and k>50 and change(k,1)>0 and k>d and mtfK>mtfD
if (longCondition)
strategy.entry("Lungo", strategy.long)
shortCondition = crossunder(mtfD, 50) and k<50 and change(k,1)<0 and k<d and mtfK<mtfD
if (shortCondition)
strategy.entry("Corto", strategy.short)
exitlong=crossunder(mtfD, upLine)
exitshort=crossover(mtfK, lowLine)
if (exitlong)
strategy.exit("Esci lungo","Lungo",trail_points=trailStep)
if (exitshort)
strategy.exit("Esci corto","Corto",trail_points=trailStep)