Back

Runtime Error: Number overflow.

So I cloned the "RSI with Martingale Position Sizing" algorithm from the university, stripped out all of the martingale logic to test a custom indicator. I was attempting to modify the custom RSI indicator and add a SMA crossover signal to it. Unfortunately I'm not well versed in C#

Does Anyone have any idea why I keep getting this error when I try and run a backtest? Here is the Stacktrace:

at System.Decimal.op_Addition (Decimal d1, Decimal d2) [0x00000] in :0
at QuantConnect.RelativeStrengthIndexCustom.UpdateDirectionalSMA (QuantConnect.FixedSizedQueue`1& queue, System.Decimal& sum, Decimal sample) [0x00000] in :0
at QuantConnect.RelativeStrengthIndexCustom.AddSample (QuantConnect.Data.Market.TradeBar bar) [0x00000] in :0
at QuantConnect.Constitution.OnData (QuantConnect.Data.Market.TradeBars data) [0x00000] in :0
at (wrapper remoting-invoke-with-check) QuantConnect.Constitution:OnData (QuantConnect.Data.Market.TradeBars)
at (wrapper dynamic-method) QuantConnect.Constitution:invoke (object,object[])
at QuantConnect.Lean.Engine.AlgorithmManager.Run (QuantConnect.Packets.AlgorithmNodePacket job, IAlgorithm algorithm, IDataFeed feed, ITransactionHandler transactions, IResultHandler results, IRealTimeHandler realtime, ICommandQueueHandler commands, CancellationToken token) [0x00000] in Lean.Engine.AlgorithmManager.Run (QuantConnect.Packets.AlgorithmNodePacket job, IAlgorithm algorithm, IDataFeed feed, ITransactionHandler transactions, IResultHandler results, IRealTimeHandler realtime, ICommandQueueHandler commands, CancellationToken token) [0x00000] in :0
Update Backtest








I figured it out, turns out I had was using the _rs instead of the acutal RSI value.
0

Just curious, why not use the built in RelativeStrengthIndex indicator? This would avoid wasting time tracking down bugs in custom implementations :)
0

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.


Well, mostly just learning but my goal is to have a moving average of the RSI that acts as a buy/sell signal.
0

If you'd like a moving average of the RSI you could use something like this:var rsi = RSI("SPY", 14);
var smaOfRsi = new SimpleMovingAverage(10).Of(rsi);

The 'Of' method here wires up the indicators such that the output from the 'rsi' is pumped into the SimpleMovingAverage, the result being an SMA of RSI :)
0

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.


Awesome! Will try that when I get home
0

Update Backtest





0

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.


Loading...

This discussion is closed