I have a Bollinger band strategy that uses 4 deviations as the stop loss but for some reason, it's not using the value that I would expect for the stop loss.
I'm just looking at the first order from the attached backtest - I'm expecting a stop loss around the 1.0979 area whereas the backtest has generated a stop loss of 1.09315. It didn't get filled because my take profit order got filled instead, but I would like to understand why my stop loss is behaving this way and how to fix it.
I have attached an image of what the chart looks like for reference. Appreciate any help that I can get on this.
Mcdawgzy
One potential thought I've had is that the Bollinger Band can be calculated using different values (open, close, OHLC/4 etc) - does anyone know what the default is for QC? I can't find anything in the documentation.
Yuri Lopukhov
In TradingView I can see the timeframe is 30 minutes, but in QuantConnect you are using Resolution.Hour, this may be the problem.
As far as I know, StandardDeviation, and by extension, BB, is using current price, i.e. Close.
Also, you are using EMA for BB, but tradingview's standard BB are using SMA.
And if you are going to use EMA in TradingView, be aware, that EMA calculation in QuantConnect and TradingView may be different. This is a common source of differences, because many indicators use EMA this way or another. By definition, EMA is recursive and do not actually have period in the same manner as SMA, every next value only depends on the previous, so to properly calculate it you need to go all the way backwards to the very first price ever. As no one does this, different systems use different rules. TradingView will only use last Period bars to calculate it. TALib, for example, would take all the data you feed to it. Some systems use Period*some_constant, where constant is for example 5. I don't know how LEAN does it, but I doubt it is the same as TradingView.
Mcdawgzy
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!