Indicators Research

Using Indicators

You can use all of the QuantConnect indicator library in your QuantBook research environment. There are 100+ indicators available. For more information on specific indicators please see the Indicators documentation.

To use an indicator in QuantBook we need to first define an instance of the indicator object. This is the fullname type of the object: e.g. BollingerBands. These type names are all listed in the Reference Table.

# Define a 10-period Bollinger bands indicator 
bb = BollingerBands(10, 2, MovingAverageType.Exponential) 

Once we have the indicator object we need to prime the indicator with historical data. We have made two helper methods qc.Indicator() for this which detects the indicator and data required and pipes historical data through it. The Indicator() method returns a dataframe.

# qb.Indicator(Indicator, Symbol, Period, Resolution)
# qb.Indicator(Indicator, Symbol, StartDate, EndDate, Resolution)

# Generate the indicator value of SPY for the last 360 days
df1_bb = qb.Indicator(bb, "SPY", 360, Resolution.Daily) 

# Generate the indicator value of EURUSD from 2017 to 2018
df2_bb = qb.Indicator(bb, "EURUSD", datetime(2017,1,1), datetime(2018,1,1), Resolution.Daily)
Request Bollinger Bands History of Specified Asset in QuantConnect Research

Plotting Indicators

Following the steps above, at this point the indicator object is ready for you to analyse. Each indicator has different properties which you can see from the Reference Table types.

In the example above the BollingerBand.StandardDeviation dataframe column is much smaller than the Upper and Lower band properties. With a little help from pandas we can drop the standard deviation column and plot the remaining ones.

# drop the standard deviation fields
df1_bb.drop('standarddeviation', 1)

# plot the Bollinger Band
Drop Column of Indicator History in QuantConnect Research
Plot Bollinger Bands in QuantConnect Research

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

Did you find this page Helpful ?