For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/
2019-10-02: The community is currently in read-only mode

Plot BuySell Observer with Tick Data



  • 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


  • administrators

    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/



  • 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!


  • administrators

    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)



  • @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!



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


Log in to reply
 

});