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/

    how to buy/sell in current (not yet closed) candle

    General Code/Help
    1
    1
    80
    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.
    • F
      Firebee last edited by

      Hi all,
      I would like to test a strategy using Bollinger Bands that:

      • If price goes below (breaks out of) bottom line of Bbands:
        • set a layer of buys at 2,4,6,8,10% lower than the price of said line.
      • sell higher (/flex, 100% winrate)

      The thing is, the logic is not that hard and I think I would know how to code it live,but I want to backtest it ofc.

      Is there a way to tell bt to buy in the same candle that breaks out of the Bbands and not at the next one once the current is closed?

      I'm imagining something that buys in the same candle if (layer 1,2,3,4,5) is at a price higher than the low of the candle, this way I'm not cheating because the price has surely been filled.

      What im missing is basically how to tell bt to buy in data[0] and not at the open of the candle after.

      Thanks to anyone who can help, and sorry if it's been asked before, I looked for an answer without luck

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