strategy · own pane · open source
Coppock Curve Strategy
Running…
Loading chart…
About
Coppock Curve momentum strategy: long when the Coppock Curve (WMA of two ROC sums) crosses above zero, exit on the cross below zero.
- Default 14/11/10 reflects Edwin Coppock's original 1962 setting.
- Combine with a higher-timeframe trend for confirmation.
- Best on monthly/weekly charts for long-term swings.
Source code
//@version=5
strategy("Coppock Curve Strategy", overlay=false, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.05)
roc1Len = input.int(14, "ROC 1 Length", minval=5, maxval=30, step=1)
roc2Len = input.int(11, "ROC 2 Length", minval=5, maxval=30, step=1)
wmaLen = input.int(10, "WMA Length", minval=5, maxval=30, step=1)
stopPct = input.float(2, "Stop Loss %", minval=0.5, maxval=10, step=0.1)
tpPct = input.float(6, "Take Profit %", minval=0, maxval=20, step=0.1)
roc1 = ta.roc(close, roc1Len)
roc2 = ta.roc(close, roc2Len)
cc = ta.wma(roc1 + roc2, wmaLen)
longSignal = strategy.position_size == 0 and ta.crossover(cc, 0)
exitSignal = strategy.position_size > 0 and ta.crossunder(cc, 0)
if longSignal
strategy.entry("Long", strategy.long)
if strategy.position_size > 0
strategy.exit("Risk", stop=stopPct > 0 ? strategy.position_avg_price * (1 - stopPct / 100) : na, limit=tpPct > 0 ? strategy.position_avg_price * (1 + tpPct / 100) : na)
if exitSignal
strategy.close("Long", comment="Coppock cross down")
hline(0, "Zero", color=color.gray, linestyle=hline.style_dotted)
p_Coppock = plot(cc, "Coppock", color=color.blue, linewidth=2)
plotshape(longSignal, "Long", style=shape.triangleup, location=location.belowbar, color=color.green, text="L")
plotshape(exitSignal, "Exit", style=shape.triangledown, location=location.abovebar, color=color.red, text="X")
alertcondition(longSignal, "Coppock long entry", "Coppock Curve crossed above zero")
alertcondition(exitSignal, "Coppock exit", "Coppock Curve crossed below zero")
No comments yet.
Sign in to comment.