Coppock Curve is a momentum indicator designed for long term trend trading. By default, it will show buy signals only on the weekly charts.
You won't be able to view it when switching to shorter timeframes like the daily, hourly, or 15 mins. The Coppock Curve indicator was made to pick trending stocks. Therefore, it will not generate any sell (short) signals.
Let's take a look at the original Coppock Curve code:
Since it did so well on the weekly chart, I decided to modify the Coppock indicator a bit to work on shorter timeframes. And to my surprise, I found a lot of nice signals during backtesting.
Here's what included in the package:
Attached below is 2 different source code. One for long strategy and other is for short strategy. I have 2 grids available on my screen so it's easier for me to view and identify which signal is which. You're more than welcome to combine into one screen. And don't forget those codes need to be added as a New Strategy, NOT indicator.
The buy (long) and sell (short) signals will be generated by the Coppock Curve indicator. As far as knowing when to take profit or cut losses, I added the 4 EMA and 9 SMA crossover for that purpose. If you have a medium to high-risk tolerance, you can wait for the EMA to fire a signal to let you know its time to take profit or cut losses.
If your risk tolerance isn't that high but you still want to maximize your profit, you can use the 13 EMA that I included instead of waiting for the crossover. Ride it until it closed above/below the opposite direction.
Example of 4/9 EMA
Example of 13 EMA
Notes:
You won't be able to view it when switching to shorter timeframes like the daily, hourly, or 15 mins. The Coppock Curve indicator was made to pick trending stocks. Therefore, it will not generate any sell (short) signals.
Let's take a look at the original Coppock Curve code:
Code:
#
# Copyright 2016 Scott J. Johnson (https://scottjjohnson.com)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS-IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# CoppockIndicator
#
# Charts the Coppock Indicator described here:
# https://en.wikipedia.org/wiki/Coppock_curve
#
# The Coppock can be used (along with other indicators like the Eureka Signal
# and IBD6000 %Es) to identify points where the stock market trend changes
# from down to up. The Coppock does not identify the beginning of downtrends.
#
# This study is designed to be applied to a major market index (e.g., SPX or
# COMP) with an aggregation period of weeks or months.
#
declare lower;
input RateOfChangeSlowPeriod = 14;
input RateOfChangeFastPeriod = 11;
input WeightedMAPeriod = 10;
def AggregationPeriod = if (getAggregationPeriod() < AggregationPeriod.WEEK) then AggregationPeriod.WEEK else getAggregationPeriod();
def price = close(period = AggregationPeriod);
def ROC1 = if price[RateOfChangeSlowPeriod]!=0 then (price/price[RateOfChangeSlowPeriod]-1)*100 else 0;
def ROC2 = if price[RateOfChangeFastPeriod]!=0 then (price/price[RateOfChangeFastPeriod]-1)*100 else 0;
plot Coppock = WMA(ROC1 + ROC2, WeightedMAPeriod);
Coppock.assignValueColor(if Coppock>Coppock[1] then color.green else color.red);
Coppock.SetDefaultColor(GetColor(1));
Coppock.setLineWeight(2);
Coppock.HideBubble();
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(color.white);
ZeroLine.HideBubble();
AddChartBubble(Coppock[1] < 0 and Coppock > Coppock[1] and Coppock[1] < Coppock[2], Coppock, "Buy", Color.CYAN, no);
Since it did so well on the weekly chart, I decided to modify the Coppock indicator a bit to work on shorter timeframes. And to my surprise, I found a lot of nice signals during backtesting.
Here's what included in the package:
- Coppock Curve strategy for short term trading
- Sell Signals (As originally stated, Coppock will look for trending stocks so it doesn't produce sell signals by default. I had to reverse some of the code for it to do so)
- 4 EMA / 9 SMA crossover for profit taking and stop loss
- 13 EMA for additional support with profit taking and minimizing losses if a trade goes wrong.
Attached below is 2 different source code. One for long strategy and other is for short strategy. I have 2 grids available on my screen so it's easier for me to view and identify which signal is which. You're more than welcome to combine into one screen. And don't forget those codes need to be added as a New Strategy, NOT indicator.
thinkScript Code for Buying
Rich (BB code):
input RateOfChangeSlowPeriod = 14;
input RateOfChangeFastPeriod = 11;
input WeightedMAPeriod = 10;
def AggregationPeriod = if (getAggregationPeriod() < AggregationPeriod.HOUR) then AggregationPeriod.HOUR else getAggregationPeriod();
def price = close(period = AggregationPeriod);
def ROC1 = if price[RateOfChangeSlowPeriod]!=0 then (price/price[RateOfChangeSlowPeriod]-1)*100 else 0;
def ROC2 = if price[RateOfChangeFastPeriod]!=0 then (price/price[RateOfChangeFastPeriod]-1)*100 else 0;
def Coppock = WMA(ROC1 + ROC2, WeightedMAPeriod);
def ZeroLine = 0;
def BuyNow = Coppock[1] < 0 and Coppock > Coppock[1] and Coppock[1] < Coppock[2];
plot Buy1 = BuyNow;
Buy1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
Buy1.SetLineWeight(1);
Buy1.AssignValueColor(Color.WHITE);
def SellNow = Coppock[1] > 0 and Coppock < Coppock[1] and Coppock[1] > Coppock[2];
#plot Sell1 = SellNow;
#Sell1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DoWN);
#Sell1.SetLineWeight(1);
#Sell1.AssignValueColor(Color.WHITE);
input priceclose = close;
input EMA = 4;
def displaceclose = 0;
input priceclose13 = close;
input EMA13 = 13;
def displaceclose13 = 0;
input pricehigh = close;
input SMA = 9;
def displacehigh = 0;
def AvgExpema = ExpAverage(priceclose[-displaceclose], EMA);
def AvgExpsma = Average(pricehigh[-displacehigh], SMA);
def AvgExp13 = ExpAverage(priceclose13[-displaceclose13], EMA13);
plot ln1 = AvgExp13;
ln1.SetDefaultColor(CreateColor(145, 210, 144));
ln1.SetLineWeight(2);
def US = AvgExpema crosses above AvgExpsma;
def DS = AvgExpema crosses below AvgExpsma ;
AddOrder(OrderType.BUY_AUTO, condition = Buy1, price = close,1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Long");
AddOrder(OrderType.SELL_AUTO, condition = DS, price = close,1, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = "Cover");
AddLabel(yes,"4/9 EMA Hidden. 13ema on",color.Yellow);
thinkScript Code for Shorting
Rich (BB code):
input RateOfChangeSlowPeriod = 14;
input RateOfChangeFastPeriod = 11;
input WeightedMAPeriod = 10;
def AggregationPeriod = if (getAggregationPeriod() < AggregationPeriod.HOUR) then AggregationPeriod.HOUR else getAggregationPeriod();
def price = close(period = AggregationPeriod);
def ROC1 = if price[RateOfChangeSlowPeriod]!=0 then (price/price[RateOfChangeSlowPeriod]-1)*100 else 0;
def ROC2 = if price[RateOfChangeFastPeriod]!=0 then (price/price[RateOfChangeFastPeriod]-1)*100 else 0;
def Coppock = WMA(ROC1 + ROC2, WeightedMAPeriod);
def ZeroLine = 0;
def BuyNow = Coppock[1] < 0 and Coppock > Coppock[1] and Coppock[1] < Coppock[2];
#plot Buy1 = BuyNow;
#Buy1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
#Buy1.SetLineWeight(1);
#Buy1.AssignValueColor(Color.WHITE);
def SellNow = Coppock[1] > 0 and Coppock < Coppock[1] and Coppock[1] > Coppock[2];
plot Sell1 = SellNow;
Sell1.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DoWN);
Sell1.SetLineWeight(1);
Sell1.AssignValueColor(Color.WHITE);
input priceclose = close;
input EMA = 4;
def displaceclose = 0;
input priceclose13 = close;
input EMA13 = 13;
def displaceclose13 = 0;
input pricehigh = close;
input SMA = 9;
def displacehigh = 0;
def AvgExpema = ExpAverage(priceclose[-displaceclose], EMA);
def AvgExpsma = Average(pricehigh[-displacehigh], SMA);
def AvgExp13 = ExpAverage(priceclose13[-displaceclose13], EMA13);
plot ln1 = AvgExp13;
ln1.SetDefaultColor(CreateColor(145, 210, 144));
ln1.SetLineWeight(2);
def US = AvgExpema crosses above AvgExpsma;
def DS = AvgExpema crosses below AvgExpsma ;
AddOrder(OrderType.SELL_AUTO, condition = Sell1, price = close,1, tickcolor = Color.LIME, arrowcolor = Color.LIME, name = "Short");
AddOrder(OrderType.BUY_AUTO, condition = US, price = close,1, tickcolor = Color.LIME, arrowcolor = Color.LIME, name = "Cover");
AddLabel(yes,"4/9 Crossover Hidden. 13ema on",color.Yellow);
About Profit Taking and Cutting Losses
The Coppock Curve will only generate buy (long) and sell (short) signals. Your job is to take profit when available. I added the 4 EMA and 9 SMA crossover for profit taking and also the 13 EMA.The buy (long) and sell (short) signals will be generated by the Coppock Curve indicator. As far as knowing when to take profit or cut losses, I added the 4 EMA and 9 SMA crossover for that purpose. If you have a medium to high-risk tolerance, you can wait for the EMA to fire a signal to let you know its time to take profit or cut losses.
If your risk tolerance isn't that high but you still want to maximize your profit, you can use the 13 EMA that I included instead of waiting for the crossover. Ride it until it closed above/below the opposite direction.
Example of 4/9 EMA
Example of 13 EMA
Notes:
- Use the 15min
- Avoid trading ETFs such as SPY, IWM, XLF, etc although ETFs can have its good days as well. But generally I would stick to individual stocks for this strategy.
Attachments
Last edited: