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/

    How can I initiate a sell based on the price value?

    General Discussion
    3
    4
    253
    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.
    • O
      Ololo last edited by

      For example, I'm running a scalping strategy and I bought some assets, so I have the buyprice. Now I want to initiate a SELL based on if the current price went up 0,5% above the buyprice. I understand how can I access the buyprice but didn't find any example with current price

      run-out 1 Reply Last reply Reply Quote 0
      • run-out
        run-out @Ololo last edited by

        @ololo I might be mistaken, but I think that if you want to set the limit price using the actual fill price of the trade, you will need to issue an order immediately after the fill, in notify_order, when the price becomes available.

        RunBacktest.com

        O 1 Reply Last reply Reply Quote 0
        • O
          Ololo @run-out last edited by

          @run-out yes I can set the limit price using the actual fill price, but I may want to cancel that order if the price goes downwards and place another order. So my question is how can I access the current price to compare it with fill price

          I 1 Reply Last reply Reply Quote 0
          • I
            incabot @Ololo last edited by

            @ololo Im new here and perhaps not much help, but from the Orders-General page in the docs:
            Member Attributes:

            ref: unique order identifier

            created: OrderData holding creation data

            executed: OrderData holding execution data

            so you can reference the order.exectuted attribute and compare with the data[0]'s which is current price of feed in handled in the strategy logic I believe.

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