Pattern recognition is a key concept in trading. This article discusses the W-M price pattern, a configuration detected on a normalized index with the aim of predicting short-term reversals.
The W-M Pattern
The W-M pattern is a price configuration seen on the normalized index which takes the close price as an input.
The normalized index takes the recent n close prices and traps them between 0 and 1 with 0 representing the lowest close price in the lookback period and 1 representing the highest close price in the lookback period. The trading conditions of the W-M pattern are as follows:
A long signal is generated whenever a successive W shape is formed on the normalized index. Similarly, the close price of the last leg of the W must not be above the previous high and the normalized index must not surpass 0.50.
A short signal is generated whenever a successive M shape is formed on the normalized index. Similarly, the close price of the last leg of the M must not be below the previous low and the normalized index must not break 0.50.
The W and M patterns should look like this:
A solid condition to the pattern is that the normalized index must not surpass 0.50 in the last step (the last leg of either W or M).
Coding the W-M Pattern
The W-M is easily coded in Trading View’s coding language, Pine Script. As it relies on simplified conditions, it becomes simple to code a recursive algorithm to scan for the signals:
You can code it yourself using Pine Script:
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Sofien-Kaabar
//@version=5
indicator("Simplified W's and M's", overlay = true)
lookback = input(defval = 14, title = 'Lookback')
normalized_price = (close - ta.lowest(close, lookback)) / (ta.highest(close, lookback) - ta.lowest(close, lookback))
bullish_w = normalized_price > 0 and normalized_price < 0.5 and normalized_price[1] == 0 and normalized_price[2] > 0 and normalized_price[3] == 0 and normalized_price[4] > 0 and close < high[1]
bearish_m = normalized_price < 1 and normalized_price > 0.5 and normalized_price[1] == 1 and normalized_price[2] < 1 and normalized_price[3] == 1 and normalized_price[4] < 1 and close > low[1]
plotshape(bullish_w, style = shape.triangleup, color = color.green, location = location.belowbar, size = size.small)
plotshape(bearish_m, style = shape.triangledown, color = color.red, location = location.abovebar, size = size.small)
The following chart shows more signals given by the pattern:
You can also check out my newsletter The Weekly Market Sentiment Report that sends weekly directional views every weekend to highlight the important trading opportunities using a mix between sentiment analysis (COT report, put-call ratio, etc.) and rules-based technical analysis.
If you liked this article, do not hesitate to like and comment, to further the discussion!