Back

Consolidated Bar Indicators

Hello, 

I'm trying to use MA's with my consolidated 15 minutes bar. I'm getting this error: 

Runtime Error: System.ArgumentException: This is a forward only indicator: EMA9(EURUSD_min) Input: 2017-01-03 00:01:00Z Previous: 2017-01-03 00:15:00Z
at QuantConnect.Indicators.IndicatorBase`1[T].Update (T input) [0x00081] in <0c58f49c73874265b0875441bb206894>:0
at QuantConnect.Algorithm.QCAlgorithm+<>c__DisplayClass382_0.<RegisterIndicator>b__1 (System.Object sender, QuantConnect.Data.IBaseData consolidated) [0x00026] in <649bb83cee5643f2928a45185f1e6abd>:0
at (wrapper delegate-invoke) <Module>:invoke_void_object_IBaseData (object,QuantConnect.Data.IBaseData)

 

This is the code:

            //Adding my Assets
            AddForex("EURUSD", Resolution.Minute);

            //Consolidating my 15 minute bar
            var signalCheck = new QuoteBarConsolidator(TimeSpan.FromMinutes(15));
            signalCheck.DataConsolidated += onsignalCheck;


            //Adding my indicators
            EMAFast = EMA("EURUSD", 9);
            EMASlow = EMA("EURUSD", 90);

            //Registering the indicators to work with the custom bar isntead of the standard resolution
            RegisterIndicator("EURUSD", EMAFast, signalCheck);
            RegisterIndicator("EURUSD", EMASlow, signalCheck);

 

Am I doing something wrong or this is a bug?

 

Update Backtest








When we use the indicator help methods, the indicator is registered, using RegisterIndicator, under the hood. You are registering the indicator twice and, consequently, updating it twice and causing that runtime error.
Instead of using the helper method, we must rely on the constructor:

EMAFast = new ExponentialMovingAverage(9);
EMASlow = new ExponentialMovingAverage(90);


 

1

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.


Thank you!

 

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