Bollinger Bands have quickly become one of the most commonly used tools in technical analysis. Bollinger Bands consist of three bands – an upper, middle and lower band – that are used to spotlight extreme short-term prices in a security. The upper band represents overbought territory, while the lower band can show you when a security is oversold. Most technicians will use Bollinger Bands in conjunction with other analysis tools.
A simple BBand strategy is buying stocks that break the lower Bollinger Band. It is expected that the price of the stock will revert back above the lower band and head toward the middle band.
# get the index constituents and loop through them constituents = common.getConstituents("CNX NIFTY") for cc in cleanConsts: ticker = cc["SYMBOL"] # get the latest technicals techs = common.getTechnicals(ticker) t = techs[len(techs)-1] # get the latest price price = common.getLivePrice(ticker) #make the decision if t["BB_DN"] > price: #there was a breakdown print "Buy:", ticker common.placeTrade(ticker, 1, "buy")
You can read the whole code on GitHub