Detecting Measured Moves with Price Swings and Fractals
Summary
The document discusses ways to identify upward and downward measured moves in candlestick price data. It defines the upward pattern as a rise to a high, a pullback that holds above the prior low, and a later advance through the earlier high; the downward pattern reverses those relationships. The question considers trend libraries, fixed candle-count rules, and geometric pattern recognition, while emphasizing that swing durations and shapes vary.
One response suggests using fractals to mark local highs and lows, then measuring moves as percentages from nearby extremes to identify trend changes. Fractal points can also be connected to form candidate channel or triangle boundaries, though their timing can differ depending on whether highs or lows are being identified. Another response offers a possible four-point slope comparison, but describes it as a priori and potentially overfit. The discussion supplies candidate heuristics rather than a validated detector, and gives no recommended lookback length, threshold, or evidence of trading performance. Any implementation would need explicit rules and testing on the intended market and timeframe.
Key ideas
- A measured move can be described through successive swing highs and lows, with the relationships reversed for upward and downward patterns.
- Fractals can identify candidate local extremes for measuring swings and connecting trend lines.
- Fixed candle-count rules may be difficult to generalize because pattern durations vary.
- Slope comparisons across the four swing points are a proposed heuristic that may overfit.
- The discussion provides no validated thresholds or evidence of trading performance.
Tags
Full text
# Python: detecting measured moves of candlestick data # Python: detecting measured moves of candlestick data 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: 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): 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. ## Answer by inquirer (score 1) https://quant.stackexchange.com/a/71732 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. ## Answer by Matthias Tom (score 1) https://quant.stackexchange.com/a/71746 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)
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.