How to plot close price +/- ATR
I havent too much experience with bt and I have an issue with a simple task.
I would realize this chart:
The profit target/loss target are simple close price +/- X times ATR(14).
I tried with following code:
# Add a ATR indicator for stop loss / take profit calculations self.atr = bt.indicators.ATR(self.datas, period=14) self.higher_band = 3*self.atr + self.dataclose self.lower_band = self.dataclose - self.atr
but I dont get higher_band/lower_band plotted on chart.
How can I do it?
In order to have something automatically plotted in
btit should be data feed, indicator or observer. So you may want to develop an indicator or observer.
On the other side, formula you are using will not give you a picture shown, it will be only a channel moving together with the close price. It will never cross the price. Hope you understand it and this formula is only first step.
Some time ago in order to develop similar picture I developed stop loss/take profit observer. Here is the link, hope it might help