Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    Plot BuySell Observer with Tick Data

    Indicators/Strategies/Analyzers
    2
    6
    554
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • emmepra
      emmepra last edited by

      Hi everyone I'm trying to plot my strategy in order to observe it and improve but one of the fundamental Observers, the BuySell one, seems to now work!

      I'm using TickData without resampling candles, OHLC values are all equal to the Price at which the tick was traded.

      Initially the arrows appeared but way too distant from the price (50/100 points away), then after reading many community threads, I've tried to set:

      cerebro = bt.Cerebro(stdstats=False)
      cerebro.addobserver(bt.observers.BuySell)
      

      And this is the result:
      Figure_0.png

      Arrows appeared but almost randomly!
      I've read that this behaviour could be cause by matplotlib misinterpreting the 0 distance between OHLC, but right now I've not found a way to handle this problem.

      Any idea about it?
      Thank you very much

      B 1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators @emmepra last edited by

        You are for sure NOT doing that.

        @emmepra said in Plot BuySell Observer with Tick Data:

        cerebro = bt.Cerebro(stdstats=False)
        cerebro.addobserver(bt.observers.BuySell)
        

        If you were the observer wouldn't say ... BuySell(True, 0). That's the problem with redacted non-working code, it is usually not the code actually executing.

        See: https://www.backtrader.com/docu/observers-reference/

        1 Reply Last reply Reply Quote 0
        • emmepra
          emmepra last edited by

          Please don’t kill me but I haven’t understood your suggestion. I’ve read the doc-page of Observers-Reference, but in my particular situation what should I do to fit those BuySell arrrows?

          Thank you so much!

          1 Reply Last reply Reply Quote 0
          • B
            backtrader administrators last edited by

            You post code which says you are doing this:

            @emmepra said in Plot BuySell Observer with Tick Data:

            cerebro = bt.Cerebro(stdstats=False)
            cerebro.addobserver(bt.observers.BuySell)
            

            But the chart shows you are NOT doing that, because the observer has the following legend: BuySellObserver(True, 0), where True is the value for the parameter barplotdist, which has a default value of False. Furthermore, the parameter bardist has a default value of 0.015 (i.e.: 1%) but the chart shows it to be 0.

            Two parameters have changed its default value as shown in the chart, but the code which supposedly doesn't work doesn't change anything.

            You may actually want to try with the code you show (I never tried it with ticks ... it may or it may not work)

            emmepra 1 Reply Last reply Reply Quote 0
            • emmepra
              emmepra @backtrader last edited by emmepra

              @backtrader Oh sure you’re totally right! I’m sorry, I’ve forgotten to say that I’ve modified the BuySell observer in order to try Barplot=True and Bardist=0, and this is the result.
              Setting both to standard False and 0.015 produce the same result, the only difference is that arrows are a little more distant than 0.

              So, I truly hope to find a solution to this behaviour since those arrows are definetely useful!

              1 Reply Last reply Reply Quote 0
              • emmepra
                emmepra last edited by

                No one has ever had this problem before? @backtrader in your opinion is it possible any workaround for this?

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
                $(document).ready(function () { app.coldLoad(); }); }