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 using day and minute data

    Indicators/Strategies/Analyzers
    2
    2
    1124
    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.
    • H
      Humbleguy last edited by

      Hi,
      I am trying to see how I can perform the following:
      Let's assume; I want to use SMA(10/SMA(50) indicator to enter and exit positions. Now I want to perform automated trading of this strategy with live data. There are two ways, I can run this in live trading:
      1 - Run the strategy everyday once at 3:59PM ET, and perform the trade.
      2 - Run the strategy every minute throughout the day. At each minute calculate the SMA(N) using close price of previous N-1 days and the latest price at the moment for this day.

      The 2nd strategy allows the algorithm to react to potential major swings throughput the day. Can the second strategy be implemented in backtrader, how?

      Thank you very much.

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        You want to use replay. The strategy doesn't actually run every minute but runs with every tick of the data, slowly recreating the day. The indicators attached to the replayed data are re-calculated automatically for the current day with each new tick (there is no need to recalculate the previous days)

        See: Docs - Data Replaying

        The length (len(data_in_use)) determines if the replaying has moved to a new day.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
        $(document).ready(function () { app.coldLoad(); }); }