For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

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.


  • 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:

    After the commit:

    Before the commit

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

  • Thanks - will test with the latest version

Log in to reply