Indicators
Plotting Indicators
Plot Update Events
To plot all of the values of some indicators, in the Initialize
initialize
method, call the PlotIndicator
plot_indicator
method. The method plots each indicator value as the indicator updates. The method accepts up to four indicators.
var symbol = AddEquity("SPY"); var smaShort = SMA(symbol, 10); var smaLong = SMA(symbol, 20); PlotIndicator("<chartName>", smaShort, smaLong)
symbol = self.add_equity("SPY") sma_short = self.sma(symbol, 10) sma_long = self.sma(symbol, 20) self.plot_indicator("<chartName>", sma_short, sma_long)
Plot Current Values
To plot the current value of indicators, call the Plot
plot
method. The method accepts up to four indicators.
// In Initialize var symbol = AddEquity("SPY"); var smaShort = SMA(symbol, 10); var smaLong = SMA(symbol, 20); // In OnData Plot("<chartName>", smaShort, smaLong)
# In Initialize symbol = self.add_equity("SPY") sma_short = self.sma(symbol, 10) sma_long = self.sma(symbol, 20) # In OnData self.plot("<chartName>", sma_short, sma_long)
View Charts
The following table describes where you can access your charts, depending on how to deploy your algorithms:
Location | Algorithm Lab Algorithms | CLI Cloud Algorithms | CLI Local Algorithms |
---|---|---|---|
Backtest results page | |||
Live results page | |||
/backtests/read endpoint | |||
/live/read endpoint | |||
ReadBacktest method | |||
ReadLiveAlgorithm method | |||
Local JSON file in your <projectName> / backtests / <timestamp> or <projectName> / live / <timestamp> directory |
Chart Limits
Not all indicators share the same base type(T), so you may not be able to plot them together since some indicators require points while others require TradeBars
.
// Plot indicators that extend the "Indicator" type PlotIndicators("All Indicator Values", sma, rsi); Plot("Current Indicator Values", sma, rsi); // Plot indicators that extend the "TradeBarIndicator" type PlotIndicators("All Indicator Values", atr, aroon); Plot("Current Indicator Values", atr, aroon);
# Plot indicators that extend the "Indicator" type self.plot_indicators("All Indicator Values", sma, rsi) self.plot("Current Indicator Values", sma, rsi); # Plot indicators that extend the "TradeBarIndicator" type self.plot_indicators("All Indicator Values", atr, aroon) self.plot("Current Indicator Values", atr, aroon);
If your indicator plots are complex, call the Plot
plot
method with one indicator and plot its Current.Value
current.value
property. For more information about plotting, see Charting.