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/

    strategy logging with trailing stop losses

    General Code/Help
    3
    5
    130
    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.
    • L
      lexar last edited by

      I'm new to backtrader and trying to create a strategy that also uses trailing stop losses.

      Is there any way to log when a position is closed due to a planned strategy vs a trailing stop loss?

      1 Reply Last reply Reply Quote 0
      • L
        lexar last edited by

        No one has any ideas?

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

          You could track you stop loss orders in a list/dictionary, and in notify_order when an order executes you could check the list, if it's in there you print or save in an analyzer.

          RunBacktest.com

          1 Reply Last reply Reply Quote 0
          • B
            booboothefool last edited by

            In notify_order, you can check if order.exectype is 5=StopTrail as opposed to whatever exectype your regular close is.

            1 Reply Last reply Reply Quote 1
            • L
              lexar last edited by

              thats great! thanks

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