该策略利用不太为人所知的Coppock曲线技术指标来实现量化交易。Coppock曲线通过计算标准普尔500指数或交易等价物的变化率的加权移动平均来派生。当Coppock曲线上穿零线时产生买入信号,下穿零线时产生卖出信号。可选择使用跟踪止损来锁定利润。该策略以$SPY的Coppock曲线作为买卖其他ETF和股票的代理信号。
该策略使用Coppock曲线作为产生交易信号的技术指标。Coppock曲线的计算公式为:
Coppock曲线 = 10周期加权移动平均(14周期变化率ROC + 11周期变化率ROC)
其中变化率ROC的计算公式为:(当前Close - N周期前Close) / N周期前Close
策略以$SPY的收盘价为基础,计算其Coppock曲线。当曲线上穿零线时产生买入信号,下穿零线时产生卖出信号。
该策略利用Coppock曲线独特的曲线形态特征来产生交易信号。相比常见指标,Coppock曲线具有更强的前瞻性。但作为独立指标其可靠性仍需验证,建议与其他因素组合使用以过滤假信号。通过参数优化、止损优化以及组合其他指标,该策略可以成为一个有效的量化交易系统。
/*backtest
start: 2023-10-13 00:00:00
end: 2023-11-12 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © RolandoSantos
//@version=4
strategy(title = "Coppock Curve", shorttitle = "Copp Curve Strat", default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000)
///trail stop
longTrailPerc = input(title="Trail Long Loss (%)", minval=0.0, step=0.1, defval=100) * 0.01
// Determine trail stop loss prices
longStopPrice = 0.0
longStopPrice := if (strategy.position_size > 0)
stopValue = close * (1 - longTrailPerc)
max(stopValue, longStopPrice[1])
else
0
//Use SPY for Copp Curve entries and exits//
security = input("SPY")
ticker = security(security, "D", close)
///Copp Curve////
wmaLength = input(title="WMA Length", type=input.integer, defval=10)
longRoCLength = input(title="Long RoC Length", type=input.integer, defval=14)
shortRoCLength = input(title="Short RoC Length", type=input.integer, defval=11)
source = ticker
curve = wma(roc(source, longRoCLength) + roc(source, shortRoCLength), wmaLength)
///Lower Band Plot///
band1 = hline(0)
band0 = hline(100)
band2 = hline(-100)
fill(band1, band0, color=color.green, transp=90)
fill(band2, band1, color=color.red, transp=90)
plot(curve, color=color.white)
///Trade Conditions///
Bull = curve > 0
Bear = curve < 0
///Entries and Exits//
if (Bull)
strategy.entry("Long", strategy.long, comment = "LE")
if (Bear)
strategy.close("Long", qty_percent=100, comment="close")
// Submit exit orders for trail stop loss price
if (strategy.position_size > 0)
strategy.exit(id="Long Trail Stop", stop=longStopPrice)