Backtrader Community

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

    Buying price in next()

    General Code/Help
    2
    3
    418
    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.
    • T
      tizenhet last edited by

      Re: How can I get the price at which buy executed?

      Hi guys,

      could you please give an example how 'to keep a reference to the order notified in notify_order, to later use it in next' (@backtrader)?
      I would like to do calculations with the buying price in the next() method.

      Thank you in advance!

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

        My very sincere advice: if you don't know how to keep a reference in a class to a value, you need to really work on the very basics of programming. And work a lot.

        It may seem very tempting to get a straight answer and go and develop a winning strategy: you won't develop any winning strategy, because so far you cannot program (which doesn't mean you cannot learn and be very good at it) and your code will be like a minefield.

        But if you wish you can google it ... or even go to Stackoverflow where someone had the same problem (which isn't really a problem)

        • https://stackoverflow.com/questions/43164468/anyone-uses-backtrader-how-can-i-keep-a-reference-in-a-method

        Choose your own path.

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

          @backtrader
          Thank you for your answer.
          I should have asked my question in a different way. I do know how to keep a reference in a class to a value but somehow it was not working in my code. Your answer opened my eyes: since I know how to program, the cause of error must have been somewhere else, not in the referencing method, so I could correct the code.

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors