Bbands using Ema instead of sma



  • Hi

    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.

    Thanks


  • administrators

    As you have already used and documented under Docs - Indicators Reference the BollingerBands can use any moving average for the calculations (it could actually use any indicator which you throw at it)

    The questions:

    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?


  • Hi

    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?


  • administrators

    The StandardDeviation would use a SimpleMovingAverage in 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:
    0_1491585617894_upload-0c1e2ef7-5351-452c-a548-d25770fb36cd

    Before the commit
    0_1491585659450_upload-5ae23cc6-6faa-4794-9f77-6ff676532856

    This will be the final straw for a release later today.



  • Thanks - will test with the latest version


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.