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/

    What is the most efficient way to detect one day is passed

    General Code/Help
    3
    6
    1000
    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
      hobart-liu last edited by

      Say I am calculating "volume-weighted-average-price". My input is 5min data. And I want to sum up to daily price. May I know what is the most efficient way to detect that "one day is passed" in my indicator?

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

        You can resample your 5 min data to daily bars and then develop an indicator based on the daily bars. More information can be found here -
        Docs - Data resampling

        1 Reply Last reply Reply Quote 0
        • H
          hobart-liu last edited by

          Actually I have daily data, but to be more accurate, I would like to use 5 min data to compute weighted-average for each 5-min, because volumes are not evenly distributed in daily high-low.

          resample, if I understand correctly, just takes peak value...

          P 1 Reply Last reply Reply Quote 0
          • H
            hobart-liu last edited by

            another case could be Accumulation Distribution Line, compute buy/sell force in each 5-min could be more accurate than just use daily based data.

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

              I didn't get what do you want, sorry. It is possible to go from 5 min data to daily bars with resample or replay, but you can't get back from daily to 5 min.

              If you have 5 min data, then use it for indicators and trade on daily bars.

              1 Reply Last reply Reply Quote 0
              • P
                Paska Houso @hobart-liu last edited by

                @hobart-liu said in What is the most efficient way to detect one day is passed:

                resample, if I understand correctly, just takes peak value...

                You understand it wrongly. Resampling accumulates the volume.

                @hobart-liu said in What is the most efficient way to detect one day is passed:

                Say I am calculating "volume-weighted-average-price". My input is 5min data. And I want to sum up to daily price. May I know what is the most efficient way to detect that "one day is passed" in my indicator?

                I don't think that "volume-weighted-average-price fits the indicator pattern. A better, imho, options would be to extend the data feed with an extra line: vwap and insert a filter which calculates the value.

                Detecting that a new day is in place can be used with the standard data.datetime.date() method (where the 1st time refers to the line name ... it has confused me too several times)

                If you want to do the same in an indicator, you need to make sure that the incoming data has a datetime capable line, which is not guaranteed, because indicators are meant to accept anything.

                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(); }); }