Back

[Debug] An object reference error working with indicators

Hi,

I'm trying to create a class that would store all my calculated data per asset. so I have this code:

public class AssetData{//class to handle all calculations of an asset
private static Symbol _Symbol;
private static ExponentialMovingAverage _EMAShort;
private static ExponentialMovingAverage _EMALong;
private static BollingerBands _BB;
private static RelativeStrengthIndex _RSI;
private static AverageTrueRange _ATR;
private static SimpleMovingAverage _SMA;
private static MovingAverageConvergenceDivergence _MACD;
private static AroonOscillator _AROON;
private static Momentum _MOM;
private static StandardDeviation _STD;

public AssetData(Symbol s){
_Symbol=s;
//Set up Indicators:
_BB = BB(_Symbol, 20, 1, MovingAverageType.Simple, Resolution.Daily);
_RSI = RSI(_Symbol, 14, MovingAverageType.Simple, Resolution.Daily);
_ATR = ATR(_Symbol, 14, MovingAverageType.Simple, Resolution.Daily);
_EMAShort = EMA(_Symbol, 9, Resolution.Daily);
_EMALong = EMA(_Symbol, 21, Resolution.Daily);
_SMA = SMA(_Symbol, 14, Resolution.Daily);
_MACD = MACD(_Symbol, 12, 26, 9, MovingAverageType.Simple, Resolution.Daily);
_AROON = AROON(_Symbol, 20, Resolution.Daily);
_MOM = MOM(_Symbol, 20, Resolution.Daily);
_STD = STD(_Symbol, 20, Resolution.Daily);
}

public void UpdateIndicators() {

}

}

and i'm getting "An object reference is required" for all the indicator setup lines.

Can anybody help defuse this?

Update Backtest








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