Navigation

    Backtrader Community

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

    Posts made by marsario

    • YahooFinance

      Hi,

      I haven't used Backtrader for over six months, and wow, none of my programs works any more :(

      The problem seems to be with YahooFinance. I saw some people have had similar problems online, but other posts didn't help me, so I thought of opening a new one.

      When I run any strategy, I get FileNotFoundError.

      In this post (https://community.backtrader.com/topic/3979/help-with-yahoofinance-data/3)
      @run-out recommended to add the following line to the file feeds/yahoo.py: sess.headers['User-Agent'] = 'backtrader'

      However, when I do that, I get TypeError.

      I'm attaching below a basic code I tested this with, and more information about the two exceptions:

      import backtrader as bt
      import datetime
      
      
      
      enddate=datetime.date.today()
      startdate = enddate - datetime.timedelta(days=(365*2))
      cerebro = bt.Cerebro()
      
      cerebro.adddata(bt.feeds.YahooFinanceData(
              dataname="AAPL",
              timeframe=bt.TimeFrame.Days,
              fromdate=startdate,
              todate=enddate,
              reverse=False,
              ))
      
      
      
      class basicStrategy(bt.Strategy):
          print("basicStrategy has been added")
              
          def __init__(self):
              print("Strategy has started. This is init")
      
          def prenext(self):
              print("Prenext")
      
          def next(self):
              firstdataname = self.datas[0]._name
              stockpricetoday = self.datas[0].close[0]
              today = bt.num2date(self.datas[0].datetime[0]).date()
              print(today,firstdataname,"is trading for",stockpricetoday)
      
      cerebro.broker.setcash(100000.0)
      cerebro.addstrategy(basicStrategy)
      print("Launching the strategy")
      cerebro.run()
      print("Strategy is over")
      
      
      
      
        File "/Users/simoneromeo/Investment Files/Learning Backtrader/67 debugging_yahoof_errors.py", line 38, in <module>
          cerebro.run()
      
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/cerebro.py", line 1127, in run
          runstrat = self.runstrategies(iterstrat)
      
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/cerebro.py", line 1210, in runstrategies
          data._start()
      
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/feed.py", line 203, in _start
          self.start()
      
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/feeds/yahoo.py", line 355, in start
          super(YahooFinanceData, self).start()
      
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/feeds/yahoo.py", line 94, in start
          super(YahooFinanceCSVData, self).start()
      
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/feed.py", line 674, in start
          self.f = io.open(self.p.dataname, 'r')
      
      FileNotFoundError: [Errno 2] No such file or directory: 'AAPL'
      
      runfile('/Users/simoneromeo/Investment Files/Learning Backtrader/67 debugging_yahoof_errors.py', wdir='/Users/simoneromeo/Investment Files/Learning Backtrader')
      basicStrategy has been added
      Launching the strategy
      Traceback (most recent call last):
      
        File "/Users/simoneromeo/Investment Files/Learning Backtrader/67 debugging_yahoof_errors.py", line 38, in <module>
          cerebro.run()
      
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/cerebro.py", line 1127, in run
          runstrat = self.runstrategies(iterstrat)
      
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/cerebro.py", line 1210, in runstrategies
          data._start()
      
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/feed.py", line 203, in _start
          self.start()
      
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/feeds/yahoo.py", line 355, in start
          # Prepared a "path" file -  CSV Parser can take over
      
      TypeError: super(type, obj): obj must be an instance or subtype of type
      
      posted in General Discussion
      M
      marsario
    • RE: Store data from Indicators for later use

      @run-out Hi! I could show the code if it really helps, but I'm looking for a way of working rather than help with a specific piece of code.

      [The Backtrader flow is:

      1. Initializing cerebro, downloading stocks data from yahoo finance or csv and creating datas
      2. Calculating the indicators (usually in init)
      3. Doing the buy and sell (usually in next)
        I'm looking for a way to avoid doing steps 1. and 2. each time, so I can only change step 3. in my trials.]

      I haven't looked into preprocessing in pandas and importing. It might be what I need, but I am not sure I understand. Would you mind expanding?

      Thanks a lot!

      posted in Indicators/Strategies/Analyzers
      M
      marsario
    • Store data from Indicators for later use

      Hi!

      I am running tests to adjust the weight of some indicators, but the code takes almost a day to run each time so it becomes very time-consuming. However, 99% of the time goes into calculating the indicators values whereas the strategy itself is relatively quick (and the strategy is the only part of the code that should change in each test, in fact). I am wondering if there could be a way to store the value of the indicators somewhere on my hard drive so they can be quickly retrieved rather than calculating them again each time.

      Do you have suggestions on how I could do that?

      Thanks a lot!

      posted in Indicators/Strategies/Analyzers
      M
      marsario
    • RE: math.log with linebuffer._LineDelay object

      @ab_trader Is there a way still to find the logarithm inside an indicator? The solution that I thought I found is a mess and it won't work.

      posted in Indicators/Strategies/Analyzers
      M
      marsario
    • RE: math.log with linebuffer._LineDelay object

      @run-out

      After some unsuccessful attempts, i came back to the strategy you recommended. I defined log like this:

      from backtrader.functions import MultiLogic
      
      
      class Log(MultiLogic):
          flogic = math.log
      

      Also, added one more line to the code you recommended so that I passed the mean to the line object:

      
      class weightedlogmeanInd(bt.Indicator):
      
          lines = ('mean',)  # output line (array)
          params = (
              ('speed', 4),
              ('tau',0.01),
          )
          
      def next(self):
          self.close_log[0] = Log(self.datas[0].close[0])
          self.change[0] = self.close_log[0] - self.close_log[-1]
          self.weighted_change[0] = self.change[0] * self.weights[0]
          self.change_sum[0] = self.change_sum[-1] + self.weighted_change[0]
          self.lines.mean[0]= bt.Sum(self.change_sum)/len(self.weights)
      

      This doesn't send an error, but doesn't behave as I wished (ideally, it should create a Mean line for each day of the datafeed. I realize that I don't understand how to use Indicators' Next method (I have created indicators but always inside Init). I wish I could find more resources to learn – Platform concepts and Indicators Development don't help me enough apparently. Do you have recommendations of how I could learn to build this indicator?

      posted in Indicators/Strategies/Analyzers
      M
      marsario
    • RE: math.log with linebuffer._LineDelay object

      @run-out

      I'm trying to implement the indicator with a different logic. And I don't understand what happens.

      class weightedlogmeanInd(bt.Indicator):
      
          lines = ('mean',)  # output line (array)
          params = (
              ('speed', 4),
              ('tau',0.01),
          )
          weights = []
      
          def __init__(self):
              self.weights = findweights(self.p.speed,self.p.tau)
              today=self.data.get(ago=0,size=len(self.weights))
              yesterday=self.data.get(ago=-1,size=len(self.weights))
              print("len(today):",len(today))
              print("len(yesterday):",len(yesterday))
              print("What is happening in today?", (today) )
              print("What is happening in yesterday?",(yesterday) )
              
              growth = np.log(today)-np.log(yesterday)
              
              print("data close:",self.data.close(0))
              print("What is happening in growth?", growth )
              
      

      The printout and error message:

      (base) Simones-Air:Learning Backtrader simoneromeo$ python 26\ onestock\ strategy.py 
      Launching the strategy
      Starting logmean strategy
      len(today): 0
      len(yesterday): 27
      What is happening in today? array('d')
      What is happening in yesterday? array('d', [133.74, 137.18, 136.76, 136.91, 136.01, 135.39, 135.13, 135.37, 133.19, 130.84, 129.71, 129.87, 126.0, 125.86, 125.35, 120.99, 121.26, 127.79, 125.12, 122.06, 120.13, 121.42, 116.36, 121.09, 119.98, 121.96, 121.03])
      Traceback (most recent call last):
        File "26 onestock strategy.py", line 150, in <module>
          cerebro.run()
       ...
        File "26 onestock strategy.py", line 46, in __init__
          growth = np.log(today)-np.log(yesterday)
      ValueError: operands could not be broadcast together with shapes (0,) (27,) 
      
      

      I don't undestand: why does self.data.get(ago=0,size=len(self.weights) return an empty array and self.data.get(ago=-1,size=len(self.weights) return an array with the right length?

      posted in Indicators/Strategies/Analyzers
      M
      marsario
    • RE: math.log with linebuffer._LineDelay object

      @run-out said in math.log with linebuffer._LineDelay object:

      def next(self):
      self.close_log[0] = bt.Log(self.datas[0].close[0])
      self.change[0] = self.close_log[0] - self.close_log[-1]
      self.weighted_change[0] = self.change[0] * self.weights[0]
      self.change_sum[0] = self.change_sum[-1] + self.weighted_change[0]

      Hi, thanks for your suggestion!

      I'm getting AttributeError that backtrader doesn't have a Log method. That's suppose to be an indicator, isn't it?

      If so I should be able to recreate it.

      posted in Indicators/Strategies/Analyzers
      M
      marsario
    • math.log with linebuffer._LineDelay object

      Hello!

      This is my indicator:

      class weightedlogmeanInd(bt.Indicator):
      
          lines = ('mean',)  # output line (array)
          params = (
              ('speed', 4),
              ('tau',0.01),
          )
      
          def __init__(self):
              weights = findweights(self.p.speed,self.p.tau) #this is an array
              change_sum = 0
              period = len(weights)
              for day in range(0,-period,-1):
                  change = self.data.close(0-day) - ( self.data.close(-1-day))
      #            change = math.log(self.data.close(0-day)) - math.log( self.data.close(-1-day))
                  weighted_change = change * weights[-day]
                  change_sum = change_sum + weighted_change 
              self.lines.mean = change_sum / period
      

      I would like to change this line:

      change = self.data.close(0-day) - ( self.data.close(-1-day))
      

      into the line below, which is now commented out:

      change = math.log(self.data.close(0-day)) - math.log( self.data.close(-1-day))
      

      When I do it, I get the following error message:

      TypeError: must be real number, not _LineDelay
      

      Basically, I would like to use the logarithm to get the price change from yesterday to today. What would be the best way to do it?

      Thanks a lot!

      posted in Indicators/Strategies/Analyzers
      M
      marsario
    • RE: Multiple datafeeds with different start dates

      @run-out

      Hi! was checking this post again, and I have to admit I didn't understand what you meant. Did you recommend downloading historical data with yfinance rather than Backtrader's YahooFinanceData method? Why?

      posted in General Discussion
      M
      marsario
    • RE: YahooFinanceCSVData & "NVDA": not working

      As you see, backtrader loads the datafeed properly but the valueerror comes as soon as run() starts.

      posted in General Code/Help
      M
      marsario
    • RE: YahooFinanceCSVData & "NVDA": not working

      @run-out

      Right! I forgot to include the error message. Here you go:

      Traceback (most recent call last):
        File "22 smooth CSV.py", line 178, in <module>
          main()
        File "22 smooth CSV.py", line 27, in main
          cerebro.run()
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/cerebro.py", line 1127, in run
          runstrat = self.runstrategies(iterstrat)
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/cerebro.py", line 1212, in runstrategies
          data.preload()
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/feed.py", line 688, in preload
          while self.load():
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/feed.py", line 479, in load
          _loadret = self._load()
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/feed.py", line 710, in _load
          return self._loadline(linetokens)
        File "/Users/simoneromeo/opt/anaconda3/lib/python3.8/site-packages/backtrader/feeds/yahoo.py", line 133, in _loadline
          o = float(linetokens[next(i)])
      ValueError: could not convert string to float: ''
      
      posted in General Code/Help
      M
      marsario
    • YahooFinanceCSVData & "NVDA": not working

      Hi,

      Something strange happens.
      I used to dowload datafeeds from yahoo with the following method, which works:

      def works(cerebro,startdate,enddate):
          
          for ticker in [
              "NVDA"
          ]:
              data = bt.feeds.YahooFinanceData(
                  dataname=ticker,
                  timeframe=bt.TimeFrame.Days,
                  fromdate=startdate,
                  todate=enddate,
                  reverse=False,
              )
              cerebro.adddata(data)
          print("Datas are added")
          return cerebro
      

      Then, I downloaded the historical data ahead of time, stored them in a CSV file and fed it into Backtrader. This works, for over 100 different tickers, but not for "NVDA":

      def doesntwork(cerebro,startdate,enddate):
          
          for ticker in [
              "NVDA"
          ]:
              modpath = os.path.dirname(os.path.abspath(sys.argv[0]))
              datapath = os.path.join(modpath, f'datafeeds/{ticker}.csv')
              data = bt.feeds.YahooFinanceCSVData(
                  dataname=datapath,
                  timeframe=bt.TimeFrame.Days,
                  fromdate=startdate,
                  todate=enddate,
                  reverse=False,
              )
              cerebro.adddata(data)
          print("Datas are added")
          return cerebro
      

      This is the file I use to download the data and to create the CSV files:

      import yfinance as yf
      import datetime
      
      enddate=datetime.date.today() 
      howmanydays=365*30 
      startdate = enddate - datetime.timedelta(days=howmanydays)
      
      for tickerSymbol in [
          "AAPL",
          "ADBE",
          "ADSK",
          ...
          "NVDA",
          ...
          "TAN",
          "VGT",
          "VOO"
      ]:
          data = yf.download(tickerSymbol, start=startdate, end=enddate)
          data.to_csv(f'{tickerSymbol}.csv')
      

      The NVDA CSV file is at this link:
      https://drive.google.com/file/d/1j_-c5tWATYe0B84YUArNF0xqBUZmArdR/view?usp=sharing

      Any idea why it doesn't work?

      posted in General Code/Help
      M
      marsario
    • RE: Custom indicator, how datas work in init

      @run-out Amazing! Thanks a lot! All clear!

      posted in Indicators/Strategies/Analyzers
      M
      marsario
    • RE: Custom indicator, how datas work in init

      @run-out

      Wow, it's really difficult for me to understand...

      I tried a different test. This is the indicator's code:

      class hasGrown(bt.Indicator):
          lines = ('hasgrown',)  # output line (array)
          
          def __init__(self):
              self.lines.hasgrown = self.data(0) > self.data(-1)
      

      and this is the strategy:

      class buyifgrewStrategy(bt.Strategy):   
          def __init__(self):
              print("Starting strategy")
              self.hasgrown = hasGrown()
              
          def next(self):
              if self.hasgrown:
                  if not self.position:
                      calculateSize(self)
                      self.buy(self.data,size=self.size)
                      print("Buying")
              else:
                  if self.position:
                      self.close(self.data)
                      print("Selling")
              log(self,f"Today: {self.data.close[0]}. Yesterday: {self.data.close[-1]}")
      

      So, in the indicator I'm checking whether the stock has price has grown yesterday (and if so I buy). If it has decreased I sell.

      The code apperently works, but I don't understand why.

      What am I comparing here? (open prices? close prices? all of them?)

              self.lines.hasgrown = self.data(0) > self.data(-1)
      

      The print output:

      ...
      2021-02-16, Today: 133.19. Yesterday: 135.37
      2021-02-17, Today: 130.84. Yesterday: 133.19
      2021-02-18, Today: 129.71. Yesterday: 130.84
      Buying
      2021-02-19, Today: 129.87. Yesterday: 129.71
      Selling
      2021-02-22, Today: 126.0. Yesterday: 129.87
      2021-02-23, Today: 125.86. Yesterday: 126.0
      2021-02-24, Today: 125.35. Yesterday: 125.86
      2021-02-25, Today: 120.99. Yesterday: 125.35
      Buying
      2021-02-26, Today: 121.26. Yesterday: 120.99
      2021-03-01, Today: 127.79. Yesterday: 121.26
      Selling
      2021-03-02, Today: 125.12. Yesterday: 127.79
      2021-03-03, Today: 122.06. Yesterday: 125.12
      2021-03-04, Today: 120.13. Yesterday: 122.06
      Buying
      2021-03-05, Today: 121.42. Yesterday: 120.13
      Strategy is over, final cash: 122076.85999999993
      
      posted in Indicators/Strategies/Analyzers
      M
      marsario
    • Custom indicator, how datas work in init

      Hi,

      I'm trying to understand how to build a custom indicator. Let's see this one:

      import backtrader as bt
      class DummyDifferenceDivider(bt.Indicator):
          lines = ('diffdiv',)  # output line (array)
          params = (
              ('period', 1),  # distance to previous data point
              ('divfactor', 2.0),  # factor to use for the division
          )
          def __init__(self):
              diff = self.data(0) - self.data(-self.p.period)
              diffdiv = diff / self.p.divfactor
              self.lines.diffdiv = diffdiv
      

      (source: https://medium.com/@danjrod/custom-indicator-development-in-python-with-backtrader-bc775552dc3e by Daniel Rodriguez)

      What does this line do?

              diff = self.data(0) - self.data(-self.p.period)
      

      Daniel writes it should be self-explanatory, but i don't understand it.

      It seems to me that he's subtracting two datafeeds (but this is impossible as I tried to run the code with only one datafeed and it runs). At first, I thought that it was subtracting the closing value of today and today-period, but I don't understand why it's not written as:

              diff = self.datas[0].close[0] - self.datas[0].close[-self.p.period]
      

      Thanks for any insights...

      posted in Indicators/Strategies/Analyzers
      M
      marsario
    • RE: AttributeError: 'Lines_LineSeries_LineIterator_DataAccessor_Indicat' object has no attribute '_addobserver'

      I just realized that I only created an indicator, but no strategy and they are two totally different things lol. All clear

      posted in Indicators/Strategies/Analyzers
      M
      marsario
    • AttributeError: 'Lines_LineSeries_LineIterator_DataAccessor_Indicat' object has no attribute '_addobserver'

      Hi, I'm learning to make a new indicator.

      I've been following these two pages:

      • https://medium.com/@danjrod/custom-indicator-development-in-python-with-backtrader-bc775552dc3e

      • https://www.backtrader.com/docu/inddev/

      When I paste the code, I get the same error message:
      AttributeError: 'Lines_LineSeries_LineIterator_DataAccessor_Indicat' object has no attribute '_addobserver'

      What is the problem?

      This is my full code:

      import datafeeds.yf as yf
      import backtrader as bt
      import datetime
      
      
      enddate=datetime.date.today()
      startdate = enddate - datetime.timedelta(days=(365*10))
      cerebro = bt.Cerebro()
      #Adding apple datafeed to cerebro:
      cerebro = yf.apple(cerebro,startdate,enddate)
      cerebro.broker.setcash(100000.0)
      print("Launching the strategy")
      cerebro.addstrategy(DummyDifferenceDivider)
      cerebro.run()
      print("Strategy is over, final cash:",cerebro.broker.getvalue())
      cerebro.plot()
      
      class DummyDifferenceDivider(bt.Indicator):
          lines = ('diffdiv',)  # output line (array)
          params = (
              ('period', 1),  # distance to previous data point
              ('divfactor', 2.0),  # factor to use for the division
          )
          def __init__(self):
              diff = self.data(0) - self.data(-self.p.period)
              diffdiv = diff / self.p.divfactor
              self.lines.diffdiv = diffdiv
      
      
      posted in Indicators/Strategies/Analyzers
      M
      marsario
    • Multiple datafeeds with different start dates

      This is a topic that has been widely discussed but I haven't seen a straightforward answer on how to work with multiple that have different start dates.

      The major challenges are:

      1. How to pass an indicator to multiple data
      2. How to start a strategy even if some of the datafeeds haven't started yet (for instance, in the case of IPOs)
      3. How to handle the datafeeds that have the right timeframe

      This is the code I came up with. It's really unclear, but I hope it can be useful for others as I struggled with this a lot. If anyone has recommendations on how to improve it, you are more than welcome!

      from __future__ import (absolute_import, division, print_function,
                              unicode_literals)
      import math
      import argparse
      import datetime
      import backtrader as bt
      import backtrader.feeds as btfeeds
      import backtrader.indicators as btind
      from backtrader import ResamplerDaily, ResamplerWeekly, ResamplerMonthly
      from backtrader import ReplayerDaily, ReplayerWeekly, ReplayerMonthly
      from backtrader.utils import flushfile
      
      def log(self, txt, dt=None):
          """ Logging function fot this strategy"""
          dt = dt or self.data.datetime[0]
          if isinstance(dt, float):
              dt = bt.num2date(dt)
          print("%s, %s" % (dt.date(), txt))
      
      class multitimeframeStrategy(bt.Strategy):
          period = 60
          wait = 0
      
      
              
          def __init__(self):
              self.mo = dict()
      
      #1) Passing the indicator to all the datas here
              for d in self.datas:
                  self.mo[d] = bt.ind.momentum(d.close, period=self.period)
      
      #2) starting a strategy even if some of the datafeeds haven't started yet her (for instance, in the case of IPOs)
          def prenext(self):
              self.next()
      
      #3) Handling the datafeeds that have the right timeframe here
          def next(self):
              self.wait = self.wait + 1
              if (self.period < self.wait):
                  best_mo_val = None
                  best_mo_data = None
                  for dmo, mom in self.mo.items():
      #3) Handling the datafeeds that have the right timeframe also here
                      if len(dmo) > self.period:
      #                    log(self,f"{dmo._name} is being analysed. it's length is {len(dmo)}",dmo.datetime[0])
                          if not best_mo_val or mom[0] > best_mo_val:
                              best_mo_val = mom[0]
                              best_mo_data = dmo
      
          #        self.log(f"{best_mo_data._name}, {best_mo_val:5.2f}")
                  for data in self.datas:
                      if data!= best_mo_data:
                          self.close(data)
                  amount_to_invest = 0.95 * self.broker.cash
                  self.size = math.floor(amount_to_invest/best_mo_data.close)
          #        self.buy(best_mo_data,percent=100)
                  self.buy(best_mo_data,size=self.size)
                  log(self,f"Buying {best_mo_data._name}")
      
      
      
      if __name__ == '__main__':
          cerebro = bt.Cerebro()
          startdate =datetime.date(2010, 7, 1)
          enddate=datetime.date(2021, 2, 1)
          """ NEW DATA PARAMETERS """
          for ticker in [
      
              "AAPL",
              "ADBE",
              "ADSK",
              "AMZN",
              "ANSS",
              "AQB",
              "ARCT",
              "AVAV",
              "AY",
              "BEEM",
              "BIDU",
              "CDNA",
              "CDXS",
              "CERS",
              "CGEN",
              "CLLS",
              "CRSP",
              "ARKW",
              "CHIK",
              "TAN",
              "VGT",
              "VOO"
          ]:
              data = bt.feeds.YahooFinanceData(
                  dataname=ticker,
                  timeframe=bt.TimeFrame.Days,
                  fromdate=startdate,
                  todate=enddate,
                  reverse=False,
              )
              cerebro.adddata(data)
          cerebro.addobserver(bt.observers.Broker)
          #    cerebro.broker.setcommission(commission=0.005)    
          print('Initial Portfolio Value: %.2f' % cerebro.broker.getvalue())
      
          cerebro.addstrategy(multitimeframeStrategy)   
          cerebro.run()
          print('Final Portfolio Value: %.2f' % cerebro.broker.getvalue())
      
      
          cerebro.plot()[0][0]
      
      
      
      posted in General Discussion
      M
      marsario
    • RE: Similar to Exponential Moving Average

      @run-out

      Hi!

      Could you check this link:
      https://docs.google.com/spreadsheets/d/1WRUfJC3VWcxCKAlXdaYAjszViJkFx__q36GKveJjEAU/edit?usp=sharing

      I'm looking for an indicator for what I called "Geometric average daily increase" (probably it's not the right name).

      I wrote a formula that creates weights so that the most recent weight is 1 and they are halved every X days (in this case every 30 days). The last weight comes after Y days (in this case 493)

      Also I take the prices of the last 494 days and do the following (basically I multiply together 493 weighted daily increases):
      product((price today/price yesterday)^today's weight)

      Finally, the 493 weights are summed all together and they root the total product above.

      Any idea, whether there exists anything similar?

      posted in Indicators/Strategies/Analyzers
      M
      marsario
    • Similar to Exponential Moving Average

      Hi,

      I'm looking for the name of an indicator but I don't know whether it exists.

      It should be similar to Exponential Moving Average but it divides the price at each day by the stock's cost on that day. In this way, it's possible to compare the average of different stocks and see which one has grown most in the recent past.

      posted in Indicators/Strategies/Analyzers
      M
      marsario
    • 1
    • 2
    • 1 / 2