Back

Indicator Extension Help

I'm still quite new to coding algos and am having some issues with the indicator extensions.  The attached backtest is an attempt at a simple pairs strategy using the ratio of SPY to XLF.  However, I can't get it to actually process any data.  Can someone help straighten me out on this?  Thanks in advance -

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.


Hi Taylor,

When we define the identity indicators, we need to specify what data they are subscribed to.

self.spy_close = self.Identity('SPY', Resolution.Daily, Field.Close)
self.xlf_close = self.Identity('XLF', Resolution.Daily, Field.Close)

This will ensure that the identity indicators are receiving the proper data. Then we create the ratio.

self.ratio = IndicatorExtensions.Over(self.spy_close, self.xlf_close)

 

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.


Thanks Rahul, that was helpful.  I'd also like to try this by using a FRAMA moving average in place of the EMA.  I think the way to do that is by using the IndicatorExtensions.Of extension, but I can't figure out the specifics for initating the FRAMA in that scenario.

0

Hey Taylor,

FRAMA is incompatible with the data type that is out put by the ratio indicator. The FRAMA indicator is a bar indicator which means it takes bar data to updated, while the ratio is a single value. This means that using IndicatorExtensions.Of(frama, ratio) will return an error.

The other option is to create a FRAMA indicator and manually update it with data

self.ratio_frama = FractalAdaptiveMovingAverage(period, longPeriod)

Then using the Updated event handler for the ratio indicator, we can efficiently update the FRAMA indicator.

self.ratio = IndicatorExtensions.Over(self.spy_close, self.xlf_close)
self.ratio.Updated = self.OnRatio

We still run into the same issue of needing a bar to update the FRAMA indicator. To work around this, we can create a custom bar with the OHLC values we desire.

self.OnRatio(self, sender, updated):
bar = TradeBar(time, symbol, open, high, low, close, volume)
self.ratio_frama.Update(bar)

Best
Rahul

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.


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