本策略通过计算两组不同参数的简单移动平均线,并以其作为建仓与平仓的信号,实现获利。该策略首先由美国交易员Richard Dennis于1983年提出,依靠简单的规则实现稳定盈利,后被Curtis Faith进一步推广,广为人知。
该策略同时计算两组快线和慢线。快线参数设置为建仓周期20天,平仓周期10天;慢线参数为建仓周期55天,平仓周期20天。当价格上穿快线建仓周期的最高值时触发建多单信号;当价格下破建仓周期的最低值时触发建空单信号。同理,当价格下穿平仓周期的最低值时平多单;当价格上破平仓周期的最高值时平空单。慢线的建仓和平仓逻辑同快线。
该策略依靠移动平均线的均线理论实现获利。即当短期平均线上穿长期平均线时,被视为价格上涨信号;下穿时则为价格下跌信号。本策略中的快线和慢线发挥着类似的作用。
本策略属于典型的趋势跟随策略。依靠简单的双重移动平均线建立交易规则,通过追踪市场趋势获得稳定收益。该策略易于理解实现,建仓信号清晰,长期实盘验证收益,非常适合初学者学习研究。同时也为更复杂的量化交易奠定基础。通过不断优化,可望获得更佳的绩效。
/*backtest
start: 2023-11-28 00:00:00
end: 2023-12-28 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
//coded by tmr0
//original idea from «Way of the Turtle: The Secret Methods that Turned Ordinary People into Legendary Traders» (2007) CURTIS FAITH
strategy("20 years old Turtles strategy by tmr0", shorttitle = "Turtles", overlay=true)
enter_fast = input(20, minval=1)
exit_fast = input(10, minval=1)
enter_slow = input(55, minval=1)
exit_slow = input(20, minval=1)
fastL = highest(enter_fast)
fastLC = lowest(exit_fast)
fastS = lowest(enter_fast)
fastSC = highest(exit_fast)
slowL = highest(enter_slow)
slowLC = lowest(exit_slow)
slowS = lowest(enter_slow)
slowSC = highest(exit_slow)
enterL1 = high > fastL[1]
exitL1 = low <= fastLC[1]
enterS1 = low < fastS[1]
exitS1 = high >= fastSC[1]
enterL2 = high > slowL[1]
exitL2 = low <= slowLC[1]
enterS2 = low < slowS[1]
exitS2 = high >= slowSC[1]
//bgcolor(exitL1 or exitL2? red: enterL1 or enterL2? navy:white)
strategy.entry("fast L", strategy.long, when = enterL1)
strategy.entry("fast S", strategy.short, when = enterS1)
strategy.close("fast L", when = exitL1)
strategy.close("fast S", when = exitS1)
strategy.entry("slow L", strategy.long, when = enterL2)
strategy.entry("slow S", strategy.short, when = enterS2)
strategy.close("slow L", when = exitL2)
strategy.close("slow S", when = exitS2)
//zl=0
//z=strategy.netprofit / 37 * koef //ежемесячная прибыль
//z=strategy.grossprofit/strategy.grossloss
//z1=plot (z, style=line, linewidth=3, color = z>zl?green:red, transp = 30)
//hline(zl, title="Zero", linewidth=1, color=gray, linestyle=dashed)