How to call price as a variable?

Sorry for such a simple post, but I couldn't find another community thread about this.

I am trying to create a variable for the price of my asset to assess whether or not it's above a set of indicators. 

I have my BB indicators assigned to self.bb1, bb2, and bb3.

I want to create an if statement that will buy or sell whenever the price is above or below the lower and upper bounds of the Bollinger Bands. 

How do I create this variable for the price? Or is there another way I should go about this that would be more efficient?

Thank you in advance, I love this platform!

Update Backtest

I'm not sure the exact code in python but I think it's self.Portfolio["SPY"(Whatever ticker in quotes)].Price


Prices for a specific symbol can be accessed via self.Securities[symbol].Price. Securities is a list of Security objects that contains all of the securities which were subscribed in Initialize() that are indexed by their symbols. 


I did try both of those as guesses previously. I remember when using:


 It threw an error, but it may have been unrelated. Thanks for the help.!


Update Backtest


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.


This discussion is closed