I have been tracking the history of several indicators the same way, but when I attempt to track my PSAR indicator, I get the following error.
Any ideas? Thanks,
Error:
Error CS0311 The type 'QuantConnect.Data.Market.IBaseDataBar' cannot be used as type parameter 'T' in the generic type or method 'HistoryTrackerImpl.Track<T>(IndicatorBase<T>, int)'. There is no implicit reference conversion from 'QuantConnect.Data.Market.IBaseDataBar' to 'QuantConnect.Data.BaseData'. QuantConnect.Algorithm.CSharp D:\Scott\OneDrive\Documents\Visual Studio 2015\Projects\Lean-master\Algorithm.CSharp\MacdEmaPsarAlgorithm.cs 119 Active
Declaration:
// define rollingwindows for indicator history public RollingWindow<IndicatorDataPoint> _MacdHistory; public RollingWindow<IndicatorDataPoint> _EmaHistory; public RollingWindow<IndicatorDataPoint> _PsarHistory;Initialization (NOTE: line 119 is the last line below [_PsarHistory =...] ):
// create a MACD and track it's history, you can access // the current value of the MACD using MacdHistory[0], // the previous value using MacdHistory[1], ect... _MacdHistory = HistoryTrackerImpl.Track(MACD(_symbol, 12, 26, 9, MovingAverageType.Exponential, Resolution.Minute), 3); // create an EMA and track it's history, you can access // the current value of the EMA using EmaHistory[0], // the previous value using EmaHistory[1], ect... _EmaHistory = HistoryTrackerImpl.Track(EMA(_symbol, 18, Resolution.Minute), 3); // create an PSAR and track it's history, you can access // the current value of the PSAR using PsarHistory[0], // the previous value using PsarHistory[1], ect... _PsarHistory = HistoryTrackerImpl.Track(PSAR(_symbol, afStart: 0.002m, afIncrement: 0.002m, afMax: 0.20m), 3);
Scott Higgins
Any suggestions for tracking PSAR history?
thanks,
Scott
Alexandre Catarino
Scott Higgins, we cannot reproduce this issue with only those code snippets.
I have writtern a algorithm where I save the PSAR history and plot two consecutive PSAR values together:
Plot("PSAR", "0", _psarWindow[0].Value); Plot("PSAR", "1", _psarWindow[1].Value);
Scott Higgins
Hello Alexandre,
I was using MichaelH's
I see you are using the rolling window and manually updating it. I will switch to manually updating rolling windows if MichaelH's class is not going to work for some indicators. FYI - I am also seeing this issue with the CCI indicator.
thanks,
Scott
Alexandre Catarino
Micheal's solution was designed for indicators of type IndicatorBase<IndicatorDataPoint>. These only need one value (open, high, low, close, etc) in their computation.
PSAR is a BarIndicator (IndicatorBase<IBaseDataBar>): it needs OHLC information.
Scott Higgins
Alexandre,
Thank you for the clarification!
Scott Higgins
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!