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/

    Having a problem with resampling

    General Code/Help
    1
    1
    66
    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.
    • leecallen
      leecallen last edited by

      I'm having kind of a fundamental problem with resampling.

      My data is M5 and I need to make decisions based on M5, H1, and H4 bars, and indicators based on those bars. For instance an H1 EMA and several H4 EMAs.

      I have always done that with resampling, and it works very well.

      Here is the problem I am having:

      Note 17:55 is the close of an M5 bar and the close of an H1 bar.
      At 17:55 I process an M5 bar and create a SELL STOP order to sell at 1.34536. That price is below the M5 close.

      My STOP order gets triggered at 17:55 - the same time I opened it!

      I think this is because

      • the H1 bar closing at 17:55 has an OHLC of 1.31927 1.35149 1.31914 1.34541 so my entry price is below the close but above the low
      • I think the BT code to evaluate the STOP order conditions is getting executed for both the M5 and H1 bars, so it gets executed again for the H1 bar, and it sees the H1 LOW below the STOP price and opens the trade.

      Is that possible?

      If so, how can I prevent that BT code from executing for my resampled H1 & H4 bars?

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