Supported Indicators
Coppock Curve
Introduction
A momentum indicator developed by Edwin “Sedge” Coppock in October 1965. The goal of this indicator is to identify long-term buying opportunities in the S&P500 and Dow Industrials. source
To view the implementation of this indicator, see the LEAN GitHub repository.
Using CC Indicator
To create an automatic indicators for CoppockCurve
, call the CC
helper method from the QCAlgorithm
class. The CC
method creates a CoppockCurve
object, hooks it up for automatic updates, and returns it so you can used it in your algorithm. In most cases, you should call the helper method in the Initialize
method.
public class CoppockCurveAlgorithm : QCAlgorithm { private Symbol _symbol; private CoppockCurve _cc; public override void Initialize() { _symbol = AddEquity("SPY", Resolution.Daily).Symbol; _cc = CC("SPY", 11, 14, 10); } public override void OnData(Slice data) { if (_cc.IsReady) { // The current value of _cc is represented by itself (_cc) // or _cc.Current.Value Plot("CoppockCurve", "cc", _cc); } } }
class CoppockCurveAlgorithm(QCAlgorithm): def Initialize(self) -> None: self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol self.cc = self.CC("SPY", 11, 14, 10) def OnData(self, slice: Slice) -> None: if self.cc.IsReady: # The current value of self.cc is represented by self.cc.Current.Value self.Plot("CoppockCurve", "cc", self.cc.Current.Value)
The following reference table describes the CC method:
CC()1/1
CoppockCurve QuantConnect.Algorithm.QCAlgorithm.CC (Symbol
symbol,*Int32
shortRocPeriod,*Int32
longRocPeriod,*Int32
lwmaPeriod,*Nullable<Resolution>
resolution,*Func<IBaseData, Decimal>
selector )
Initializes a new instance of the CoppockCurve" indicator.
If you don't provide a resolution, it defaults to the security resolution. If you provide a resolution, it must be greater than or equal to the resolution of the security. For instance, if you subscribe to hourly data for a security, you should update its indicator with data that spans 1 hour or longer.
For more information about the selector argument, see Alternative Price Fields.
For more information about plotting indicators, see Plotting Indicators.
You can manually create a CoppockCurve
indicator, so it doesn't automatically update. Manual indicators let you update their values with any data you choose.
Updating your indicator manually enables you to control when the indicator is updated and what data you use to update it. To manually update the indicator, call the Update
method with time/number pair, or an IndicatorDataPoint
. The indicator will only be ready after you prime it with enough data.
public class CoppockCurveAlgorithm : QCAlgorithm { private Symbol _symbol; private CoppockCurve _cc; public override void Initialize() { _symbol = AddEquity("SPY", Resolution.Daily).Symbol; _cc = new CoppockCurve(11, 14, 10); } public override void OnData(Slice data) { if (data.Bars.TryGeValue(_symbol, out var bar)) { _cc.Update(bar.EndTime, bar.Close); } if (_cc.IsReady) { // The current value of _cc is represented by itself (_cc) // or _cc.Current.Value Plot("CoppockCurve", "cc", _cc); } } }
class CoppockCurveAlgorithm(QCAlgorithm): def Initialize(self) -> None: self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol self.cc = CoppockCurve(11, 14, 10) def OnData(self, slice: Slice) -> None: bar = slice.Bars.get(self.symbol) if bar: self.cc.Update(bar.EndTime, bar.Close) if self.cc.IsReady: # The current value of self.cc is represented by self.cc.Current.Value self.Plot("CoppockCurve", "cc", self.cc.Current.Value)
To register a manual indicator for automatic updates with the security data, call the RegisterIndicator
method.
public class CoppockCurveAlgorithm : QCAlgorithm { private Symbol _symbol; private CoppockCurve _cc; public override void Initialize() { _symbol = AddEquity("SPY", Resolution.Daily).Symbol; _cc = new CoppockCurve(11, 14, 10); RegisterIndicator(_symbol, _cc, Resolution.Daily); } public override void OnData(Slice data) { if (_cc.IsReady) { // The current value of _cc is represented by itself (_cc) // or _cc.Current.Value Plot("CoppockCurve", "cc", _cc); } } }
class CoppockCurveAlgorithm(QCAlgorithm): def Initialize(self) -> None: self.symbol = self.AddEquity("SPY", Resolution.Daily).Symbol self.cc = CoppockCurve(11, 14, 10) self.RegisterIndicator(self.symbol, self.cc, Resolution.Daily) def OnData(self, slice: Slice) -> None: if self.cc.IsReady: # The current value of self.cc is represented by self.cc.Current.Value self.Plot("CoppockCurve", "cc", self.cc.Current.Value)
The following reference table describes the CoppockCurve constructor:
CoppockCurve()1/3
CoppockCurve QuantConnect.Indicators.CoppockCurve ( )
Initializes a new instance of the CoppockCurve
indicator with its default values.
CoppockCurve()2/3
CoppockCurve QuantConnect.Indicators.CoppockCurve (int
shortRocPeriod,int
longRocPeriod,int
lwmaPeriod )
Initializes a new instance of the CoppockCurv
indicator.
CoppockCurve()3/3
CoppockCurve QuantConnect.Indicators.CoppockCurve (string
name,int
shortRocPeriod,int
longRocPeriod,int
lwmaPeriod )
Initializes a new instance of the CoppockCurve
indicator.
Visualization
The following image shows plot values of selected properties of CoppockCurve
using the plotly library.
