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

Can't get DirectionalMovement working -- different from TradingView/TOS



  • Hi there,

    I'm new to backtrader and am excited but I'm having some issues replicating the Directional Movement Indicator in TradingView inside of the built-in indicators.

    For example, you can see here the DI+ and DI- values from Trading view for /ES futures with 5 minute bars on 4/19/2020 at 11:30 PM EDT of DI+: 27.05 and DI-: 14.34.

    This is how I've initialized:

    self.dm = bt.indicators.DirectionalMovement(period=14)

    On the next command I'm getting values via this syntax self.dm.DIplus[0] and self.dm.DIminus[0]

    No matter what bar I try, I'm getting values like these:

    self.dm.DIminus[0]
    Out[2]: 98.09214728939715
    self.dm.DIplus[0]
    Out[3]: 0.49034550756342365
    

    I have checked ThinkOrSwim to make sure there isn't an issue with DMI and saw very, very close values for DI+ and DI-, both are using 14 periods and I could confirm at least that ThinkOrSwim was using Wilder's SmoothedMovingAverage.

    I've been banging my head against the wall on this, would appreciate any insight.

    tradingview.png



  • show please the script you run and piece of the data. i'll try to run it by myself.


Log in to reply
 

});