Hello,
I am trying to use the PSAR indicator on a moving average to take out noise from raw stock data. But I am receiving an error when I try (see the backtest). I have used the .Of extension before for indicators like PercentRateOfChange where there is only a look back period for a variable, so I wasn't sure how to input the 3 variables of PSAR. The backtest has the indicatorextension.of(PSAR) commented out as it produces an error if not.
If someone can show me how to input the PSAR with the indicatorextension.of that would be fantastic.
Thank you,
Tate
Vladimir
Tate Linzel,
His may help.
Tate Linzel
Hi Vladimir,
No this does not help. I was looking to have the Parabolic SAR use the Hull Moving Average as the data input instead of the stock price, I was looking to smooth out the noise of the stock raw data. I also tried switching around the your coded to do what I want:
self.hma = self.HMA(self.stock, PERIOD, Resolution.Minute)
self.Parabolic = self.PSAR(self.stock, 0.02, 0.02, 0.20, Resolution.Minute)
self.ParabolicHMA = IndicatorExtensions.Of(self.PSAR(self.stock, 0.02, 0.02, 0.20, Resolution.Minute), self.hma)
But it still give me an error:
"Runtime Error: IndicatorBase.Update() 'input' expected to be of type QuantConnect.Data.Market.IBaseDataBar but is of type QuantConnect.Indicators.IndicatorDataPoint (Open Stacktrace)"
Is there another way to change the input data for the PSAR indicator?
Thank you for your help.
Derek Melchin
Hi Tate,
This issue is that the HMA only produces a single value while the PSAR expects a bar of data as input. To resolve the issue, we can manually create a TradeBar with the HMA values and use it to update the PSAR.
def Initialize(self): # ... self.Firsthma = self.HMA(self.Firststock, self.FirstHMAPeriod, Resolution.Minute) self.Firsthma.Updated += self.consolidation_handler self.Parabolic = ParabolicStopAndReverse(0.02, 0.02, .2) def consolidation_handler(self, sender, bar): if self.Firsthma.IsReady: hma = self.Firsthma.Current.Value trade_bar = TradeBar(bar.EndTime, self.spy.Symbol, hma, hma, hma, hma, 0) self.Parabolic.Update(trade_bar)
See the attached backtest for reference.
Best,
Derek Melchin
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.
Tate Linzel
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!