Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. chuka
    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 1
    • Followers 0
    • Topics 6
    • Posts 14
    • Best 0
    • Groups 0

    chuka

    @chuka

    0
    Reputation
    886
    Profile views
    14
    Posts
    0
    Followers
    1
    Following
    Joined Last Online

    chuka Unfollow Follow

    Latest posts made by chuka

    • RE: Data Backfilling Issue
      data0 = oandastore.getdata(dataname="GBP_USD", account_tmout=15,
                                 timeframe=bt.TimeFrame.Ticks,ignore_heartbeat=True,
                                 use_positions = True,
                                 fromdate=StartDate,
                                 compression=1, backfill_start=True, backfill=False)
      

      Is it true? @backtrader

      posted in General Code/Help
      chuka
      chuka
    • RE: Data Backfilling Issue
      StartDate = '2019-06-23T12:00:00'
      StartDate = datetime.datetime.strptime(StartDate,'%Y-%m-%dT%H:%M:%S' )
      End = '2019-06-24T00:00:00'
      End = datetime.datetime.strptime(End,'%Y-%m-%dT%H:%M:%S' )
      
      datahist = oandastore.getdata(dataname="GBP_USD", account_tmout=15,
                                  timeframe=bt.TimeFrame.Minutes,
                                  historical = True, compression = 1,
                                  fromdate=StartDate, todate=End)
      
      data0 = oandastore.getdata(dataname="GBP_USD", account_tmout=15,
                                 timeframe=bt.TimeFrame.Ticks,ignore_heartbeat=True,
                                 compression=1, backfill_start=datahist, backfill=False)
      
      #This is setting what timeframe we want to use.
      cerebro.resampledata(data0, timeframe=bt.TimeFrame.Minutes, compression=1)
      cerebro.addstrategy(TestStrategy)
      

      This code doesn't work? How to do?

      posted in General Code/Help
      chuka
      chuka
    • RE: Data Backfilling Issue

      I'm using oanda. How to backfill
      now or live start time -2019-6-29 8:52
      my ML working on 100 hour data
      so how to backfill before 100 hour data from oanda in start?

      posted in General Code/Help
      chuka
      chuka
    • How continue live trade after historical download?
      1. Download historical - > Training ML model
      2. Continue live trade - > Trained model
      posted in General Code/Help
      chuka
      chuka
    • OandapyV20: Tick to OHLC

      Tick stream structure:
      {
      'type': 'PRICE',
      'time': '2018-01-12T20:59:01.706352414Z',
      'bids': [
      {'price': '13227.9', 'liquidity': 25},
      {'price': '13227.8', 'liquidity': 25},
      {'price': '13227.7', 'liquidity': 50},
      {'price': '13227.5', 'liquidity': 50},
      {'price': '13227.3', 'liquidity': 50}],
      'instrument': 'DE30_EUR',
      'status': 'non-tradeable',
      'asks': [
      {'price': '13229.8', 'liquidity': 50},
      {'price': '13229.9', 'liquidity': 50},
      {'price': '13230.1', 'liquidity': 50},
      {'price': '13230.3', 'liquidity': 50}],
      'closeoutAsk': '13230.3',
      'closeoutBid': '13227.3',
      'tradeable': False}

      is it true?

          # Common fields
          self.lines.datetime[0] = parse_date(msg['time'])
          self.lines.volume[0] = 0.0
          self.lines.openinterest[0] = 0.0
      
          # Put the prices into the bar
          tick = float(msg['asks'][0]['price']) if self.p.useask else float(msg['bids'][0]['price'])
          
          self.lines.open[0] = tick
          self.lines.high[0] = tick
          self.lines.low[0] = tick
          self.lines.close[0] = tick
          self.lines.volume[0] = 0.0
          self.lines.openinterest[0] = 0.0
      
      posted in General Code/Help
      chuka
      chuka
    • RE: Oanda v20 API

      @matthias-janssen said in Oanda v20 API:

      Thank you for contacting OANDA.
      Unfortunately that is not possible , our V1 API will be phasing out by the end of the ye

      @backtrader

      posted in General Code/Help
      chuka
      chuka
    • RE: Oanda test

      @backtrader

      I can not open v1 demo account. Could anyone open?

      I can only open v20 account. And This support oandaV20 api. Pls help me.

      Use v20 REST API only if you have a v20 account
      Use v1 REST API if your account id contains only digits (ie. 2534253) as it is a legacy account

      0_1515409909241_acc.png

      posted in General Code/Help
      chuka
      chuka
    • RE: Oanda test

      @holicst Did you fix it?
      0_1515395051224_test1.png

      posted in General Code/Help
      chuka
      chuka
    • Zigzag indicator

      I'm new, Can anyone help me ? /zigzag indicator/
      http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:zigzag
      https://github.com/joshuaulrich/TTR/blob/master/src/zigzag.c
      @backtrader @ab_trader

      class Zigzag(bt.Indicator):
          
          lines = ('zigzag',)
          plotinfo = dict(subplot=False)
          params = (
              ('change', 40),
              ('use_percent', False),
              ('use_retrace', False),
              ('use_last_ex', False),
          )
      
          def __init__(self):
      
              self.reference = {
                  'price': None,
                  'index': None,
              }
              self.inflection = {
                  'price': None,
                  'index': None,
              }
              if self.params.use_percent:
                  self.change = self.params.change / 100.0
              else:
                  self.change = self.params.change
              
              self.reference['price'] = (self.data.high.array[0] + self.data.low.array[0]) / 2
              self.reference['index'] = 0
              self.inflection['price'] = (self.data.high.array[0] + self.data.low.array[0]) / 2
              self.inflection['index'] = 1
      
              self.extreme_min = 0.0
              self.extreme_max = 0.0
              self.local_min = 0.0
              self.local_max = 0.0        
              self.signal = 0
              self.i = 0
              
         
          def next(self):
              
      
              self.i = len(self.data.open)-1
              # Initialize all zigzag values to NA 
              self.zigzag.array.append(NAN)
              
              if self.params.use_percent:
                  #If % change given (absolute move)      
                  self.extreme_min = self.inflection['price'] * (1.0 - self.change)
                  self.extreme_max = self.inflection['price'] * (1.0 + self.change)
              else:
                  #If $ change given (only absolute moves make sense) 
                  self.extreme_min = self.inflection['price'] - self.change
                  self.extreme_max = self.inflection['price'] + self.change
      
              #Find local maximum and minimum
      
              
              self.local_max = self.inflection['price'] if self.inflection['price'] > self.data.high.array[self.i] else self.data.high.array[self.i]
              self.local_min = self.inflection['price'] if self.inflection['price'] < self.data.low.array[self.i] else self.data.low.array[self.i]
              
              ##Find first trend 
              if self.signal == 0:
                  if self.params.use_retrace:
                      #Retrace prior move 
                      self.signal = 1 if (self.inflection['price'] >= self.reference['price']) else -1
                  else:
                      #Absolute move
                      if self.local_min <= self.extreme_min:
                          #Confirmed Downtrend
                          self.signal = -1
      
      
                      if self.local_max >= self.extreme_max:
                          #Confirmed Uptrend 
                          self.signal = 1
      
              ##Downtrend
              if self.signal == -1:
                  #New Minimum
                  if self.data.low.array[self.i] == self.local_min:
                      #Last Extreme
                      if self.params.use_last_ex:
                          self.inflection['price'] = self.data.low.array[self.i]
                          self.inflection['index'] = self.i
                      else:
                          #First Extreme 
                          if (self.data.low.array[self.i] != self.data.low[-1]):
                              self.inflection['price'] = self.data.low.array[self.i]
                              self.inflection['index'] = self.i
      
                  #Retrace prior move
                  if self.params.use_retrace:
                      self.extreme_max = self.inflection['price'] +((self.reference['price'] - self.inflection['price']) * self.change)
      
                  #Trend Reversal 
                  if self.data.high.array[self.i] >= self.extreme_max:
                      self.zigzag[self.reference['index']] = self.reference['price']
                      self.reference = copy.copy(self.inflection)
                      self.inflection['price'] = self.data.high.array[self.i]
                      self.inflection['index'] = self.i
                      self.signal = 1
      
      
              #Uptrend 
              if self.signal == 1:
      
                  #New Maximum
                  if self.data.high.array[self.i] == self.local_max:
                      #Last Extreme 
                      if self.params.use_last_ex:
                          self.inflection['price'] = self.data.high.array[self.i]
                          self.inflection['index'] = self.i
                      else:
                          #First Extreme 
                          if (self.data.high.array[self.i] != self.data.high[-1]):
                              self.inflection['price'] = self.data.high.array[self.i]
                              self.inflection['index'] = self.i
      
                  #Retrace prior move 
                  if self.params.use_retrace:
                      self.extreme_min = self.inflection['price'] -((self.inflection['price'] - self.reference['price']) * self.change)
      
                  #Trend Reversal
                  if (self.data.low.array[self.i] <= self.extreme_min):
                      self.zigzag[self.reference['index']] = self.reference['price']
                      self.reference = copy.copy(self.inflection)
                      self.inflection['price'] = self.data.low.array[self.i]
                      self.inflection['index'] = self.i
                      self.signal = -1
      
                  self.i = self.i + 1
                  
              self.zigzag[self.reference['index']] = self.reference['price']
              self.zigzag[self.inflection['index']] = self.inflection['price']
      

      0_1513851289023_Simple-ZigZag-indicator-for-MetaTrader-5.png

      posted in Indicators/Strategies/Analyzers
      chuka
      chuka
    • RE: Machine learning + backtrader

      ok, many thanks @ab_trader

      posted in General Discussion
      chuka
      chuka