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/

    The best method to detect changing of direction of an indicator?

    General Code/Help
    1
    1
    91
    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.
    • Quỳnh H Nguyễn
      Quỳnh H Nguyễn last edited by

      Hello,

      There are some ways to detect changing of direction of an indicator:

      1. Calculate the slope or correlation of N period of a line. Reference to: https://realpython.com/python-statistics/ . Increasing when correlation is positive, and vice versa decreasing when correlation is negative.
      2. Calculate the percent change of N period of a line. Reference to: bt.indicators.RateOfChange or bt.indicators.PercentChange. Increasing when percent change positive and decreasing when percent change negative.

      The first method is slow and lagging so much with big N, but not accurate with small N.

      The second method is more accurate with small N and especially with stable/no-lag indicator, example: Fisher Transform, but it got the problem when the indicator signal cross ZERO line.

      d6e098b5-a4bc-4662-a78a-0c880bda271e-image.png

      Do you have any better ideas to solve this problem? I can imagine one method to solve the second method is plus a number to the signal line, for all positive number to void the ZERO line crossing. But I hope that you have a better ideas.

      Thank you very much!

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