Here is the simple code to try out Stoch indicator and I got divide by 0 exception.
Stack trace is at the end of this code
namespace QuantConnect
{
/*
* QuantConnect University: Bollinger Bands Example:
*/
public class IndicatorSuiteAlgorithm : QCAlgorithm
{
string _symbol = "ACWI";
Stochastic _sto = null;
//Initialize the data and resolution you require for your strategy:
public override void Initialize()
{
//Initialize
SetStartDate(2015, 6, 1);
SetEndDate(DateTime.Now.Date.AddDays(-1));
SetCash(25000);
//Add as many securities as you like. All the data will be passed into the event handler:
AddSecurity(SecurityType.Equity, _symbol, Resolution.Minute);
_sto = STO(_symbol, 14, 1, 1, Resolution.Minute);
}
public void OnData(TradeBars data)
{
if (!_sto.IsReady) return;
Plot("STO", _sto);
}
}
}
=====================
at System.Decimal.op_Division (Decimal d1, Decimal d2) [0x00000] in :0
at QuantConnect.Indicators.Stochastic.ComputeFastStoch (Int32 period, QuantConnect.Data.Market.TradeBar input) [0x00000] in :0
at QuantConnect.Indicators.Stochastic+<>c__DisplayClass12.<.ctor>b__0 (QuantConnect.Data.Market.TradeBar input) [0x00000] in :0
at (wrapper delegate-invoke) System.Func`2:invoke_TResult_T (QuantConnect.Data.Market.TradeBar)
at QuantConnect.Indicators.FunctionalIndicator`1[QuantConnect.Data.Market.TradeBar].ComputeNextValue (QuantConnect.Data.Market.TradeBar input) [0x00000] in :0
at QuantConnect.Indicators.IndicatorBase`1[QuantConnect.Data.Market.TradeBar].Update (QuantConnect.Data.Market.TradeBar input) [0x00000] in :0
at QuantConnect.Indicators.Stochastic.ComputeNextValue (QuantConnect.Data.Market.TradeBar input) [0x00000] in :0
at QuantConnect.Indicators.IndicatorBase`1[QuantConnect.Data.Market.TradeBar].Update (QuantConnect.Data.Market.TradeBar input) [0x00000] in :0
at QuantConnect.Algorithm.QCAlgorithm+<>c__DisplayClass18`1[QuantConnect.Data.Market.TradeBar].b__17 (System.Object sender, QuantConnect.Data.BaseData consolidated) [0x00000] in :0
at QuantConnect.Data.Consolidators.DataConsolidator`1[QuantConnect.Data.Market.TradeBar].OnDataConsolidated (QuantConnect.Data.BaseData consolidated) [0x00000] in :0
at QuantConnect.Data.Consolidators.IdentityDataConsolidator`1[QuantConnect.Data.Market.TradeBar].Update (QuantConnect.Data.Market.TradeBar data) [0x00000] in :0
at QuantConnect.Data.Consolidators.DataConsolidator`1[QuantConnect.Data.Market.TradeBar].Update (QuantConnect.Data.BaseData data) [0x00000] in :0
at QuantConnect.Lean.Engine.AlgorithmManager.Run (QuantConnect.Packets.AlgorithmNodePacket job, IAlgorithm algorithm, IDataFeed feed, ITransactionHandler transactions, IResultHandler results, IRealTimeHandler realtime, CancellationToken token) [0x00000] in Lean.Engine.AlgorithmManager.Run (QuantConnect.Packets.AlgorithmNodePacket job, IAlgorithm algorithm, IDataFeed feed, ITransactionHandler transactions, IResultHandler results, IRealTimeHandler realtime, CancellationToken token) [0x00000] in :0
Michael Handschuh
Desi Monk
Jared Broad
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Desi Monk
Desi Monk
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!