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/

    Take Profit-Stoploss and Log the result

    Indicators/Strategies/Analyzers
    1
    1
    90
    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.
    • Bryan Moreno
      Bryan Moreno last edited by

      Hey everyone!
      Finally sign up to the community got fixed and I can ask this! Haha

      From this topic take profit- stop loss I learned to set profit and stoploss when taking a LONG trade. However, should the Order change when taking a SHORT trade?

              if conditions and not self.position:
                  self.long_buy_order = self.buy_bracket(
                      data=self.datas[0],
                      size=1,
                      exectype=bt.Order.Limit,  # Stop?
                      plimit=price,
                      stopprice=price_stoploss,
                      stopexec=bt.Order.Stop,  # Limit?
                      limitprice=price_target,
                      limitexec=bt.Order.Limit,  # Stop?
                  )
      

      Plus, is there a way to LOG the result of the trade?
      I wanna train a supervised ML model and I would need to know if the trade filled the target or the stoploss.
      Many thanks in advance!

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