Bbands using Ema instead of sma
Can I use ema instead of default sma for bbands indicator? I tried to pass bt.indicators.MovAv.EMA to param movav when creating bands , the code starts and run without isssue but the bbands top and bot values are much bigger than the expected value.. it works perfectly fine with sma.
As you have already used and documented under Docs - Indicators Reference the
BollingerBandscan use any moving average for the calculations (it could actually use any indicator which you throw at it)
but the bbands top and bot values are much bigger than the expected value
- What is the expected value?
- Do you have a reference to compare against?
Here is one example:
Live data from IB on AUD-201706-GLOBEX
bbands with SMA: (period=20, devfactor=2.0) top: 0.751921 mid: 0.751146 bot: 0.750371 2017-04-07T14:21:30 bbands with EMA: (period=20, devfactor=2.0, movav=bt.indicators.MovAv.EMA) top: 0.792232 mid: 0.751423 bot: 0.710615 2017-04-07T14:21:30
Compare to IB, the EMA top and bot point in the program are much higher (IB value : top 0.7524 bot: 0.7504) but the mid point matches at 0.751423. Also SMA values matches with IB.
Any suggestion how I can further check on this?
StandardDeviationwould use a
SimpleMovingAveragein all cases. This seems to have a jumping-jack effect for the values.
This commit makes the BollingerBands pass the chosen moving average: https://github.com/mementum/backtrader/commit/817fed29ccb7374e38bd0ab700f96fd4737ba514
After the commit:
Before the commit
This will be the final straw for a release later today.
Thanks - will test with the latest version