Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Indicator on Indicator (EMA smoothing on RSI)

    Indicators/Strategies/Analyzers
    2
    3
    336
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Jeffrey C F Wong
      Jeffrey C F Wong last edited by

      Hi everyone, I am trying to apply some EMA smoothing on the RSI indicator. But so far, no luck. Would really appreciate if someone can point me to the right direction...

      class RSI(bt.Strategy):
      
          params = (('period', 14),)
      
          def __init__(self):
              self.rsi = bt.indicators.RSI_Safe(self.close, period=14)
          
          def __init__(self):     
              self.smooth_rsi = bt.indicators.ExpSmoothing(self.rsi, period=8)
      
      1 Reply Last reply Reply Quote 0
      • R
        rajanprabu last edited by

        hi @Jeffrey-C-F-Wong

        When you pass close to RSI indicator.. its self.data.close not self.close

        class RSI(bt.Strategy):
        
            params = (('period', 14),)
        
            def __init__(self):
                self.rsi = bt.indicators.RSI_Safe(self.data0.close, period=14)
                self.smooth_rsi = bt.indicators.ExpSmoothing(self.rsi, period=8)
        
        Jeffrey C F Wong 1 Reply Last reply Reply Quote 2
        • Jeffrey C F Wong
          Jeffrey C F Wong @rajanprabu last edited by

          @rajanprabu thank you so much, that makes sense and it's working great!

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors