Coppock Curve Day Trading Indicator & Strategy for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
Warehouse
Coppock Curve is a momentum indicator designed for long term trend trading. You can check out the original indicator for ThinkorSwim here. By default, it will show buy signals on the weekly charts and nothing else.

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.

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 = open,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.
 
Last edited:
G

GeneHo

New member
VIP
Hi Ben, how can I get the code?

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@GeneHo Click on the link under _thinkScript code_.

 
Last edited:
markos

markos

Well-known member
VIP
Warehouse
What you have created with a "monthly" type indicator is really cool. I may be able to adapt that to my time frames.

Thanks!

 
Last edited:
N

Nick

Member
VIP
Understood this is suitable for 15mins timeframe, may i know if there is any suggested modifications for daily timeframe? thank you

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@Nick All you have to do is adjust the fourth line of the code.

Rich (BB code):
def AggregationPeriod = if (getAggregationPeriod() < AggregationPeriod.HOUR) then AggregationPeriod.HOUR else getAggregationPeriod();
Change _HOUR_ to _DAY_ &#128512;

 
Last edited:
V

vandell001

New member
VIP
What code would be used to change it to 15min time frame.

 
Last edited:
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@vandell001#1439 By changing
Code:
AggregationPeriod.HOUR
to
Code:
AggregationPeriod.FIFTEEN_MIN
 
Last edited:
N

Nick

Member
VIP
@BenTen will there be a short or down arrow plotted on the chart after the scan list is generated? I am able to generate the scan list based on the short code above but there is no arrows plotted on the chart. thanks
 

Top