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/

    Send new trade at open

    General Discussion
    2
    4
    104
    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.
    • D
      damiano last edited by

      Hello everybody!
      Reading the doc https://www.backtrader.com/docu/cerebro/ i found the following note:

      In step 1 above when the data feeds deliver the new set of bars, those bars are closed. This means the data has already happened.
      

      It is correct, of course, to avoid look-ahead bias and provide reliable backtests, but there are strategies that need a different timing of entry.

      For example, please consider a classical crossover strategy based on a simple moving average on OPEN PRICE.

      In that case if the open price is crossing the moving average (based on OPEN PRICE too) i should put my order there without waiting the next candle. Why should my order be executed on the next candle?

      Maybe it is a rare situation, and prevent look ahead is correct too. But if all my strategy is based on opens i should execute my order at open price, without waiting the next new candle.

      Does it make sense?

      A 1 Reply Last reply Reply Quote 0
      • A
        ab_trader @damiano last edited by

        @damiano

        you may want to read docs further and find out cheat-on-open feature, which allows to trade using open prices.

        working with the daily bars and making decisions on the open (ie inside the bar) is cheating and should be done considering accurate slippage, since it takes some time to make a decision (5 min, 10 min, 30 sec whatever). Make a trade on the exact open price is sometime impossible, especially on the very quick markets. For example, I was founding the case when simulating the trade on the open gives profitable strategy, but use of the price at 5 min after open was breaking the strategy.

        • If my answer helped, hit reputation up arrow at lower right corner of the post.
        • Python Debugging With Pdb
        • New to python and bt - check this out
        D 1 Reply Last reply Reply Quote 1
        • D
          damiano @ab_trader last edited by

          @ab_trader

          Thank you! I did not reach that part of doc, grr.. sorry.
          Ok, so the good thing is that we can send order on open too. Yeah the slippage "problem" is correct, you are right, i need to handle it carefully.

          However, i also have read that we can run some optimizers giving a range of indicator's parameters, the optimizer basically find the best set of parameters. It could be useful for me but, again, there maybe be a problem with timing.

          Suppose the same crossover strategy with a simple moving average, and run the optimizer to test the moving average on Open, High, Low, Close ... is there a way to set that COO parameter WHEN the base price of that indicator is "open" ?

          A 1 Reply Last reply Reply Quote 0
          • A
            ab_trader @damiano last edited by

            @damiano said in Send new trade at open:

            Suppose the same crossover strategy with a simple moving average, and run the optimizer to test the moving average on Open, High, Low, Close ... is there a way to set that COO parameter WHEN the base price of that indicator is "open" ?

            I don't understand your question. You can create your simple moving average on any time series in bt. cheat-on-open is independent from the indicators.

            • If my answer helped, hit reputation up arrow at lower right corner of the post.
            • Python Debugging With Pdb
            • New to python and bt - check this out
            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors