3
$\begingroup$

Goal:

I'm looking to see if it's possible to programatically detect "measured moves" on candlestick data. The price data I am using is successfully retrieved from the TD Ameritrade platform using the unofficial Python API.

Details:

For an "upwards measured move", this is where the price reaches both higher lows and higher highs on a candlestick chart. For a "downwards measured move", the price reaches both lower highs and lower lows.

A very simplified image of the measured move trendline shape I'm looking to programmatically detect can be seen below:

(Left) Upwards Measured Move, and (Right) Downwards Measured Move:

enter image description here

As can be seen from the "upwards measured move", the price moves up from points A to B. After B, the price falls to point C (which this time is a "higher low" than A). Finally, the price moves to point D, on its way passing the price level of point B. The exact opposite can be said for "downwards measured moves".

An example of both upwards (green) and downwards (red) measured moves can be seen below on an Amazon chart using drawn trendlines (please ignore the 5 horizontal(ish) regression lines):

enter image description here

Questions:

Q1. Is there a Python library that can detect these measured move?

Q2. If there is no library that can exclusively detect measured moves, could a library such as trendet (which detects trends in price data) be used in the following context:

  • If a downtrend is detected, which is
  • Followed by an uptrend that doesn't reach as high of a price level, which is
  • Finally followed by another downtrend where the price falls lower than the point B level,

then a downward measured move has been detected, for example?

Q3. Again if there is no library and trendet isn't viable, could something like the following logic work? For example,

  • If the current price continues to fall lower than the previous X candles,

  • and then the price reverses and rises for X candles but doesn't reach the same level,

  • before finally falling again for another X candles,

then a "downwards measured move" has been detected? The issue here is the question of how many candles could be appropriate?

Q4. Could some pattern recognition to detect a triangular shape work? I guess another issue with this would stem from the fact that most of the triangles are rarely the same shame (which is evident in the second image).

If anyone has any knowledge they wouldn't mind sharing, or could point me in a direction where I can learn about some resources to help in detecting measured moves, I would really appreciate it.

$\endgroup$

2 Answers 2

1
$\begingroup$

You can use fractals to identify highs and lows. You can also measure movements as a percentage of the nearest extreme points. Here I showed how to find down fractals, and here I measured movements in percentages to detect a trend change. As for the triangle, you can apply the same fractals and connect them with lines (two upper, two lower). But, there is a subtle point here. For example, the lower fractals will be earlier than the upper ones and vice versa. Since the market is not homogeneous and different periods are needed to search for fractals.

$\endgroup$
1
$\begingroup$

I can only offer apriori solutions which are slightly overfit:

  • to calculate the slope of N lookback periods and drop the ones that have a low and high std dev (how to determine low and high?)
  • the pattern you are trying to track has 4 points, xN. it seems that the slope of (x1 - x2) = (x3 - x4), so in order to identify a proper pattern, you just need the slope of (x2 - x3)*-1 to = the slope of (x1 - x2) OR (x3 - x4)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.