Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. ylu
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
    Y
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 4
    • Best 1
    • Groups 0

    ylu

    @ylu

    1
    Reputation
    1
    Profile views
    4
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    ylu Unfollow Follow

    Best posts made by ylu

    • RE: Closed trade list (including MFE/MAE) analyzer

      I am so happy to find this. I want to buy some chocolate for you <3

      posted in Indicators/Strategies/Analyzers
      Y
      ylu

    Latest posts made by ylu

    • RE: Closed trade list (including MFE/MAE) analyzer

      I am so happy to find this. I want to buy some chocolate for you <3

      posted in Indicators/Strategies/Analyzers
      Y
      ylu
    • RE: RSI is buying at wrong value

      Now it did not close position.. what is wrong ??
      c05198f9-1a2f-4aab-960b-c1501b6dd3ea-image.png

          def next(self):
              if self.order:
                  return  # pending order execution
              if not self.position:
                  if self.trendline > 0:
                      if self.rsi < 45:
                          self.order = self.buy()
      
              if self.position:
                      if self.rsi >= 65:
                          self.close()
                      if self.data.close[0] <= self.sma:
                          self.close()
      
      

      Is that happening to only me ??

      posted in General Code/Help
      Y
      ylu
    • RE: RSI is buying at wrong value

      Check this out;
      a4ad95a5-a442-481e-9c89-3492519c34a4-image.png
      and this one;
      3accda91-a1d3-4de0-ba78-1c86ad1fa4c1-image.png

      posted in General Code/Help
      Y
      ylu
    • RSI is buying at wrong value

      Hello everyone, I am working on improve my TA skills to hit a career on Investment Banking so that i am interested on backtests by backtrader.
      I have a problem about RSI indicator. I am writing many statements but it is still close.buy over RSI 70.
      Here is my code related RSI.

          def __init__(self):
              self.EMAh = bt.talib.EMA(self.data.close, timeperiod = 8)
              self.EMAo = bt.talib.EMA(self.data.close, timeperiod = 18)
              self.EMAy = bt.talib.EMA(self.data.close, timeperiod = 27)
      
              self.crossoverhy = self.EMAh - self.EMAy               
              self.crossoveroy = self.EMAo - self.EMAy               
              self.crossoverho = self.EMAh - self.EMAo
              self.x = self.EMAy - self.data.close[0]
              self.y = self.EMAo - self.data.close[0]
              self.z = self.EMAh - self.data.close[0]
              # Control marketh trend  
              self.sma = bt.indicators.SMA(self.data.close, period=self.p.smaperiod)
              self.smadir = self.sma - self.sma(-self.p.dirperiod)
              self.rsi = bt.talib.RSI(self.data.close, period=36)
              self.trendline = self.data.close[0] - self.sma
      
      

      and,

          def next(self):
              if self.order:
                  return 
              if not self.position:
                  if self.trendline > 0:
                          if self.rsi < 45:
                              self.order = self.buy()
      
              if self.position:
                  if self.trendline > 0:
                      if self.rsi > 70:
                          self.close()
      
      

      Here is plot:
      cc31d515-6298-4196-a85f-6028ccff9a82-image.png

      What is wrong with my code, what it is not selling at this point and if I keep adding 3EMA method it is buying when RSI 80.
      Why this is happening ?
      Thank you for your time.

      posted in General Code/Help
      Y
      ylu