Back

How to use two securities in one indicator

I would like to use two securities in One indicator, to create an indicator Relative Strength of one security with respect to another. I wan tot know the components of this type of indicator. Does anyone have anything like this they would be willing to share?
Update Backtest








You can chain indicators, maybe this will suit your needs? Its called the "Of" composite extension:
https://lean.quantconnect.com/docs#topic11.html
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.


Well, What I plan to do is for example: take the SMA of AAPL( or any other security) and divide it by the SMA of SPY( only SPY), the result, is my Indicator Value( this would give me the movement of one in relation to another)... In other words, I want to call a specific indicator of a specific security( SPY in this case) inside the indicator class.
0


// In initialize:
_smaAAPL = SMA("AAPL", 100);
_smaSPY = SMA("SPY", 100);
_emaRatio = _smaAAPL.Over(_smaSPY);
2

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.


That's Where my issue comes up. I was under the impression that to create an Indicator you need a constructor, an IsReady() method and a ComputeNextValue() Method. but I was looking around the Solution and cant find the Initialize method to Override inside the indicator classes.
0

The indicator's don't have an Initialize method. Any initialization would have to be performed in the constructor. Does the example provided by Jared work for your use case? If not, please let me know more details about what you're trying to do, such as the desired inputs, outputs, and the math required to get there :)
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.


Unfortunatelly is not helping me.... I need to access indicator values of SMA (anySymbol) and SMA of the "SPY" inside the indicator class( the custom indicator i am trying to make). Thoses two values i will save them into two local variables, in order to find their ratio. In other words...

My indicator value returned in the ComputeNextValue() method = SMA(anySymbol)/ SMA("SPY"), what this does, is creating a ratio of how much a stock changes compared to SPY. Inside a strategy you would be able to do what Jared explains. But inside an indicator, is what has me stuck...

once i have that indicator done, i will create my startegy, to loop through my stocks universe(which I already have on a CSV file), scores them and organizes them based on this indicator value.
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