Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. Sahli Simo
    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 1
    • Best 0
    • Groups 0

    Sahli Simo

    @Sahli Simo

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

    Sahli Simo Unfollow Follow

    Latest posts made by Sahli Simo

    • Indicators & Machine Learning

      Lets say that I developed an indicator to predict stock prices for the following 5 days.
      I followed your tutorial and I could write a custom indicator class. But I couldnt assign the values for the coming 4 days for example. Maybe the following code will show the problem

      class AlphayaPredictor(bt.Indicator):
        lines = ('lstm',)
        params = (('period', 5),)
      
        plotinfo = dict(subplot=False)
      
        # def __init__(self):
        #     self.addminperiod(self.params.period)
      
        def next(self):
          # datasum = math.fsum(self.data.get(size=self.params.period))
          current_date = self.datas[0].datetime
          prices = [[self.data.open[-i],
                           self.data.high[-i],
                           self.data.low[-i],
                           self.data.close[-i],
                           self.data.volume[-i]
                           ] for i in range(self.params.period-1,-1,-1)]
          pred_prices = predict_future_prices(prices)    # it returns a list of future prices
      
          for i in range(self.params.period):
                  self.lines.lstm[i] = pred_prices[i]        # <---- here is the problem
          # self.lines.lstm[0] = pred_prices[0]          # <---- this is okay, but it's not my objective.
      

      Could u plz tell me how to do it? I appreciate your help.

      posted in Indicators/Strategies/Analyzers
      Sahli Simo
      Sahli Simo