Algorithm Reference

Indicators

Introduction

We provide more than 100 technical indicators for you to use in your algorithm. These are provided in two ways; through helper short cut methods, and as class objects. Indicators created through the short cut methods have already been wired up to receive data and are "ready to use". A full list of the indicators and their properties can be found in the reference table below.

One key indicator to learn is the Identity indicator which simply returns the value of the asset. This can be useful for combining indicators together. For example:

var pep = Identity("PEP");    // Pepsi ticker

var coke = Identity("KO");    // Coke ticker
var delta = pep.Minus(coke);  // Difference between them

Indicator Ready

Indicators are not ready when you first create them. The length of time it takes to trust the indicator values depends on the indicator period. In QuantConnect we provide a shortcut to check the indicator status. indicator.IsReady will return true when the indicator is ready to be used. eg. IsReady

	if not self.indicator.IsReady:
		return
	if (!indicator.IsReady) return;

Reference Table

Indicators Usage
AccelerationBands var abands = ABANDS(Symbol symbol, int period, decimal width = 4, MovingAverageType movingAverageType = null, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.TradeBar] selector = null)
AccumulationDistribution var ad = AD(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.TradeBar] selector = null)
AccumulationDistributionOscillator var adosc = ADOSC(Symbol symbol, int fastPeriod, int slowPeriod, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.TradeBar] selector = null)
AverageDirectionalIndex var adx = ADX(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
AverageDirectionalMovementIndexRating var adxr = ADXR(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
ArnaudLegouxMovingAverage var alma = ALMA(Symbol symbol, int period, int sigma = 6, decimal offset = 0.85, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
AbsolutePriceOscillator var apo = APO(Symbol symbol, int fastPeriod, int slowPeriod, MovingAverageType movingAverageType, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
AroonOscillator var aroon = AROON(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
AroonOscillator var aroon = AROON(Symbol symbol, int upPeriod, int downPeriod, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
AverageTrueRange var atr = ATR(Symbol symbol, int period, MovingAverageType type = null, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
BollingerBands var bb = BB(Symbol symbol, int period, decimal k, MovingAverageType movingAverageType = null, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
BalanceOfPower var bop = BOP(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
CoppockCurve var cc = CC(Symbol symbol, int shortRocPeriod = 11, int longRocPeriod = 14, int lwmaPeriod = 10, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
CommodityChannelIndex var cci = CCI(Symbol symbol, int period, MovingAverageType movingAverageType = null, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
ChandeMomentumOscillator var cmo = CMO(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
DonchianChannel var dch = DCH(Symbol symbol, int upperPeriod, int lowerPeriod, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
DonchianChannel var dch = DCH(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
DoubleExponentialMovingAverage var dema = DEMA(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
DetrendedPriceOscillator var dpo = DPO(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
ExponentialMovingAverage var ema = EMA(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
FractalAdaptiveMovingAverage var frama = FRAMA(Symbol symbol, int period, int longPeriod = 198, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
HullMovingAverage var hma = HMA(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
IchimokuKinkoHyo var ichimoku = ICHIMOKU(Symbol symbol, int tenkanPeriod, int kijunPeriod, int senkouAPeriod, int senkouBPeriod, int senkouADelayPeriod, int senkouBDelayPeriod, Resolution resolution = null)
KaufmanAdaptiveMovingAverage var kama = KAMA(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
KeltnerChannels var kch = KCH(Symbol symbol, int period, decimal k, MovingAverageType movingAverageType = null, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
LogReturn var logr = LOGR(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
LeastSquaresMovingAverage var lsma = LSMA(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
LinearWeightedMovingAverage var lwma = LWMA(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
MovingAverageConvergenceDivergence var macd = MACD(Symbol symbol, int fastPeriod, int slowPeriod, int signalPeriod, MovingAverageType type = 1, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
MeanAbsoluteDeviation var mad = MAD(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
MassIndex var mass = MASS(Symbol symbol, int emaPeriod = 9, int sumPeriod = 25, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.TradeBar] selector = null)
Maximum var max = MAX(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
MoneyFlowIndex var mfi = MFI(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.TradeBar] selector = null)
MidPoint var midpoint = MIDPOINT(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
MidPrice var midprice = MIDPRICE(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
Minimum var min = MIN(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
Momentum var mom = MOM(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
MomersionIndicator var momersion = MOMERSION(Symbol symbol, int minPeriod, int fullPeriod, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
MomentumPercent var momp = MOMP(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
NormalizedAverageTrueRange var natr = NATR(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
OnBalanceVolume var obv = OBV(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.TradeBar] selector = null)
PercentagePriceOscillator var ppo = PPO(Symbol symbol, int fastPeriod, int slowPeriod, MovingAverageType movingAverageType, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
ParabolicStopAndReverse var psar = PSAR(Symbol symbol, decimal afStart = 0.02, decimal afIncrement = 0.02, decimal afMax = 0.2, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
RegressionChannel var rc = RC(Symbol symbol, int period, decimal k, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
RateOfChange var roc = ROC(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
RateOfChangePercent var rocp = ROCP(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
RateOfChangeRatio var rocr = ROCR(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
RelativeStrengthIndex var rsi = RSI(Symbol symbol, int period, MovingAverageType movingAverageType = 2, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
SimpleMovingAverage var sma = SMA(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
StandardDeviation var std = STD(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
Stochastic var sto = STO(Symbol symbol, int period, int kPeriod, int dPeriod, Resolution resolution = null)
Stochastic var sto = STO(Symbol symbol, int period, Resolution resolution = null)
Sum var sum = SUM(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
SwissArmyKnife var swiss = SWISS(Symbol symbol, int period, Double delta, SwissArmyKnifeTool tool, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
T3MovingAverage var t3 = T3(Symbol symbol, int period, decimal volumeFactor = 0.7, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
TripleExponentialMovingAverage var tema = TEMA(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
TrueRange var tr = TR(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
TriangularMovingAverage var trima = TRIMA(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
Trix var trix = TRIX(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
UltimateOscillator var ultosc = ULTOSC(Symbol symbol, int period1, int period2, int period3, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
Variance var var = VAR(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
VolumeWeightedAveragePriceIndicator var vwap = VWAP(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.TradeBar] selector = null)
IntradayVwap var vwap = VWAP(Symbol symbol)
WilliamsPercentR var wilr = WILR(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
WilderMovingAverage var wwma = WWMA(Symbol symbol, int period, Resolution resolution = null, Func`2[Data.IBaseData,Decimal] selector = null)
Candlesticks Patterns Usage
TwoCrows var twocrows = CandlestickPatterns.TwoCrows(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
ThreeBlackCrows var threeblackcrows = CandlestickPatterns.ThreeBlackCrows(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
ThreeInside var threeinside = CandlestickPatterns.ThreeInside(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
ThreeLineStrike var threelinestrike = CandlestickPatterns.ThreeLineStrike(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
ThreeOutside var threeoutside = CandlestickPatterns.ThreeOutside(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
ThreeStarsInSouth var threestarsinsouth = CandlestickPatterns.ThreeStarsInSouth(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
ThreeWhiteSoldiers var threewhitesoldiers = CandlestickPatterns.ThreeWhiteSoldiers(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
AbandonedBaby var abandonedbaby = CandlestickPatterns.AbandonedBaby(Symbol symbol, decimal penetration = 0.3, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
AdvanceBlock var advanceblock = CandlestickPatterns.AdvanceBlock(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
BeltHold var belthold = CandlestickPatterns.BeltHold(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
Breakaway var breakaway = CandlestickPatterns.Breakaway(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
ClosingMarubozu var closingmarubozu = CandlestickPatterns.ClosingMarubozu(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
ConcealedBabySwallow var concealedbabyswallow = CandlestickPatterns.ConcealedBabySwallow(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
Counterattack var counterattack = CandlestickPatterns.Counterattack(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
DarkCloudCover var darkcloudcover = CandlestickPatterns.DarkCloudCover(Symbol symbol, decimal penetration = 0.5, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
Doji var doji = CandlestickPatterns.Doji(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
DojiStar var dojistar = CandlestickPatterns.DojiStar(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
DragonflyDoji var dragonflydoji = CandlestickPatterns.DragonflyDoji(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
Engulfing var engulfing = CandlestickPatterns.Engulfing(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
EveningDojiStar var eveningdojistar = CandlestickPatterns.EveningDojiStar(Symbol symbol, decimal penetration = 0.3, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
EveningStar var eveningstar = CandlestickPatterns.EveningStar(Symbol symbol, decimal penetration = 0.3, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
GapSideBySideWhite var gapsidebysidewhite = CandlestickPatterns.GapSideBySideWhite(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
GravestoneDoji var gravestonedoji = CandlestickPatterns.GravestoneDoji(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
Hammer var hammer = CandlestickPatterns.Hammer(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
HangingMan var hangingman = CandlestickPatterns.HangingMan(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
Harami var harami = CandlestickPatterns.Harami(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
HaramiCross var haramicross = CandlestickPatterns.HaramiCross(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
HighWaveCandle var highwavecandle = CandlestickPatterns.HighWaveCandle(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
Hikkake var hikkake = CandlestickPatterns.Hikkake(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
HikkakeModified var hikkakemodified = CandlestickPatterns.HikkakeModified(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
HomingPigeon var homingpigeon = CandlestickPatterns.HomingPigeon(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
IdenticalThreeCrows var identicalthreecrows = CandlestickPatterns.IdenticalThreeCrows(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
InNeck var inneck = CandlestickPatterns.InNeck(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
InvertedHammer var invertedhammer = CandlestickPatterns.InvertedHammer(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
Kicking var kicking = CandlestickPatterns.Kicking(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
KickingByLength var kickingbylength = CandlestickPatterns.KickingByLength(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
LadderBottom var ladderbottom = CandlestickPatterns.LadderBottom(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
LongLeggedDoji var longleggeddoji = CandlestickPatterns.LongLeggedDoji(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
LongLineCandle var longlinecandle = CandlestickPatterns.LongLineCandle(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
Marubozu var marubozu = CandlestickPatterns.Marubozu(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
MatchingLow var matchinglow = CandlestickPatterns.MatchingLow(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
MatHold var mathold = CandlestickPatterns.MatHold(Symbol symbol, decimal penetration = 0.5, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
MorningDojiStar var morningdojistar = CandlestickPatterns.MorningDojiStar(Symbol symbol, decimal penetration = 0.3, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
MorningStar var morningstar = CandlestickPatterns.MorningStar(Symbol symbol, decimal penetration = 0.3, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
OnNeck var onneck = CandlestickPatterns.OnNeck(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
Piercing var piercing = CandlestickPatterns.Piercing(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
RickshawMan var rickshawman = CandlestickPatterns.RickshawMan(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
RiseFallThreeMethods var risefallthreemethods = CandlestickPatterns.RiseFallThreeMethods(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
SeparatingLines var separatinglines = CandlestickPatterns.SeparatingLines(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
ShootingStar var shootingstar = CandlestickPatterns.ShootingStar(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
ShortLineCandle var shortlinecandle = CandlestickPatterns.ShortLineCandle(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
SpinningTop var spinningtop = CandlestickPatterns.SpinningTop(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
StalledPattern var stalledpattern = CandlestickPatterns.StalledPattern(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
StickSandwich var sticksandwich = CandlestickPatterns.StickSandwich(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
Takuri var takuri = CandlestickPatterns.Takuri(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
TasukiGap var tasukigap = CandlestickPatterns.TasukiGap(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
Thrusting var thrusting = CandlestickPatterns.Thrusting(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
Tristar var tristar = CandlestickPatterns.Tristar(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
UniqueThreeRiver var uniquethreeriver = CandlestickPatterns.UniqueThreeRiver(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
UpsideGapTwoCrows var upsidegaptwocrows = CandlestickPatterns.UpsideGapTwoCrows(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)
UpDownGapThreeMethods var updowngapthreemethods = CandlestickPatterns.UpDownGapThreeMethods(Symbol symbol, Resolution resolution = null, Func`2[Data.IBaseData,Data.Market.IBaseDataBar] selector = null)

// 1. Using basic indicator at the same resolution as source security:
// TIP -> You can use string "IBM" or the security.Symbol object
var ema = EMA("IBM", 14);
var rsi = RSI("IBM", 14);

//2. Using indicator at different (higher) resolution to the source security:
var emaDaily = EMA("IBM", 14, Resolution.Daily);

//3. Indicator of a different property (default is close of bar/data):
// TIP -> You can use helper methods Field.Open, Field.High etc on the indicator selector:
var emaDailyHigh = EMA("IBM", 14, Resolution.Daily, point => ((TradeBar) point).High);

//4. Using the indicators:
//4.1  Setup in initialize:
_emaFast = EMA("IBM", 14);
_emaSlow = EMA("IBM", 28);

//4.2 Use in OnData:
if (_emaSlow.IsReady && _emaFast.IsReady) {
   if (_emaFast > _emaSlow) {
       //Long.
   } else if (_emaFast < _emaSlow) {
       //Short.
   } 
}

//NOTE. Some indicators require tradebars (ATR, AROON) so your selector must return a TradeBar object for those indicators.
# 1. Using basic indicator at the same resolution as source security:
self.ema = self.EMA("IBM", 14)
self.rsi = self.RSI("IBM", 14)

#2. Using indicator at different (higher) resolution to the source security:
self.emaDaily = self.EMA("IBM", 14, Resolution.Daily)

#3. Indicator of a different property (default is close of bar/data):
self.emaDailyHigh = self.EMA("IBM", 14, Resolution.Daily, Field.High)


#4. Using the indicators:
#4.1  Setup in initialize: make sure you've asked for the data for the asset.
self.AddEquity("IBM")
self.emaFast = self.EMA("IBM", 14);
self.emaSlow = self.EMA("IBM", 28);

#4.2 Consume the indicators in OnData.
if self.emaSlow.IsReady and self.emaFast.IsReady:
    if self.emaFast.Current.Value > self.emaSlow.Current.Value:
        self.Debug("Long")
    elif self.emaFast.Current.Value < self.emaSlow.Current.Value:
        self.Debug("Short")

Indicator Extensions

Indicators are composable - meaning they can be chained together to create unique combinations much like lego blocks. We support several indicator extensions as outlined below:

Extension Example Usage
.Plus()
var emaSum = ema5.Plus(ema20);
Add a fixed value or indicator value to another indicator
.Minus()
var emaDelta = ema20.Minus(ema5);
Find the difference between two indicators
.Times()
var rsiSafe = rsi.Times(0.95);
Multiply one indicator or constant value by another.
.Over()
var emaAverage = ema5.Plus(ema10).Over(2);
Divide indicator chain by constant or indicator.
.Of()
var sma = new SimpleMovingAverage("SPY", 14);
var rsiAverage= sma.Of( rsi );
Feed an indicator output into input of another.
.SMA(int period)
var rsiAvg = rsi.SMA(10);
Of extension helper for SMA method.
.EMA(int period)
var rsiAvg = rsi.EMA(10);
Of extension helper for EMA method.
.MAX(int period)
var rsiMax = rsi.MAX(10);
Of extension helper for MAX method, get max in i-samples.
.MIN(int period)
var rsiMin = rsi.MIN(10);
Of extension helper for MIN method, get min in i-samples.

Extension Example Usage
.Plus()
emaSum = IndicatorExtensions.Plus(ema20, ema5)
Add a fixed value or indicator value to another indicator
.Minus()
emaDelta = IndicatorExtensions.Minus(ema5, ema20)
Find the difference between two indicators
.Times()
rsiSafe = IndicatorExtensions.Times(rsi, 0.95)
Multiply one indicator or constant value by another.
.Over()
emaAverage = IndicatorExtensions.Over(IndicatorExtensions.Plus(ema10, ema5), 2)
Divide indicator chain by constant or indicator.
.Of()
sma = SimpleMovingAverage("SPY", 14)
rsiAverage= IndicatorExtensions.Of(rsi, sma)
Feed an indicator output into input of another.
.SMA(int period)
rsiAvg = IndicatorExtensions.SMA(rsi, 10)
Of extension helper for SMA method.
.EMA(int period)
rsiAvg = IndicatorExtensions.EMA(rsi, 10)
Of extension helper for EMA method.
.MAX(int period)
rsiMax = IndicatorExtensions.MAX(rsi, 10)
Of extension helper for MAX method, get max in i-samples.
.MIN(int period)
rsiMin = IndicatorExtensions.MIN(rsi, 10)
Of extension helper for MIN method, get min in i-samples.

public class IndicatorTests : QCAlgorithm
{
    //Save off reference to indicator objects
    RelativeStrengthIndex _rsi;
    SimpleMovingAverage _rsiSMA;

    public override void Initialize()
    {
       //In addition to other initialize logic:
       _rsi = RSI("SPY", 14); // Creating a RSI
       _rsiSMA = _rsi.SMA(3); // Creating the SMA on the RSI
    }
    
    public override void OnData(Slice data)
    {
       Plot("RSI", _rsi, _rsiSMA);
    }
}
class IndicatorTests(QCAlgorithm):
    def Initialize():
       # In addition to other initialize logic:
       self.rsi = self.RSI("SPY", 14)                     # Creating a RSI
       self.rsiSMA = IndicatorExtensions.SMA(self.rsi, 3) # Creating the SMA on the RSI
       self.PlotIndicator("RSI", self.rsi, self.rsiSMA)

Plotting Indicators

We provide a helper method which aims to make plotting indicators simple. For further information on the charting API please see our Charting section.

Plot(string chart, Indicator[] indicators)
self.Plot(string chart, Indicator[] indicators)

Note that not all indicators share the same base type(T) so may not work together as some indicators require points where others require TradeBars.

//Plot array of indicator objects; extending "Indicator" type.
Plot("Indicators", sma, rsi); 

//Plot array of indicator objects; extending "TradeBarIndicator" type.
Plot("Indicators", atr, aroon); 

//For complex plotting it might be easiest to simply plot your indicators individually.
#Plot array of indicator objects; extending "Indicator" type.
self.Plot("Indicators", sma, rsi); 

#Plot array of indicator objects; extending "TradeBarIndicator" type.
self.Plot("Indicators", atr, aroon); 

#Currently, there is a limit of 4 indicators for each Plot call
#For complex plotting it might be easiest to simply plot your indicators individually.

You can also see our Tutorials and Videos. You can also get in touch with us via Chat.

Did you find this page Helpful ?