Navigation

    Backtrader Community

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

    Vandit D Jain

    @Vandit D Jain

    0
    Reputation
    3
    Profile views
    2
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    Vandit D Jain Unfollow Follow

    Latest posts made by Vandit D Jain

    • RE: Newbie error in both RSI and MACD

      @run-out I mean there is no error message. My algorithm seems to always underperform in MACD.

      posted in General Code/Help
      Vandit D Jain
      Vandit D Jain
    • Newbie error in both RSI and MACD

      Both my strategies work fine when going long individually. However they don't work together. Can someone please help?

      Here is my MACD code:

      def next(self):
                  if self.position.size== 0:
                      if ((self.crossover >0)& (self.macd.macd>0) & (self.macd.signal>0)) :
                          amount_to_invest=self.params.order_percentage*self.broker.cash
                          self.size=math.floor(amount_to_invest/self.data.close)
                          
                          print("BUY CREATED at {}".format(self.data.close[0]))
                          self.order= self.buy(size= self.size) 
                      elif ((self.crossover <0)& (self.macd.macd<0) & (self.macd.signal<0)) :
                          amount_to_invest=self.params.order_percentage*self.broker.cash
                          self.size=math.floor(amount_to_invest/self.data.close)
                          
                          print("SELL at {}".format(self.data.close[0]))
                          self.order= self.sell(size= self.size)
                  elif (self.position.size >0):
                      if ((self.crossover <0)&(self.order.isbuy())):
                          print("close at {}".format(self.data.close[0])) 
                          self.close()
                      elif ((self.crossover>0) & (self.order.issell())):
                          print("close at {}".format(self.data.close[0])) 
                          self.close()
      

      Here is my RSI code:

      def next(self):
                  if self.position.size== 0:
                      if self.rsi < self.params.lowerbound:
                          amount_to_invest=self.params.order_percentage*self.broker.cash
                          self.size=math.floor(amount_to_invest/self.data.close)
                              
                          print("BUY at {}".format(self.data.close[0]))
                          self.buy(size= self.size)
                      elif self.rsi> self.params.upbound:
                          amount_to_invest=self.params.order_percentage*self.broker.cash
                          self.size=math.floor(amount_to_invest/self.data.close)
                              
                          print("SELL Created at {}".format(self.data.close[0]))
                          self.sell(size= self.size)
                  
                  if self.position.size > 0:
                      if (self.rsi < self.params.upbound) or ( self.rsi> self.params.lowerbound):
                           print("Sell at {}".format(self.data.close[0])) 
                           self.close()'''
      posted in General Code/Help
      Vandit D Jain
      Vandit D Jain