OPEN-SOURCE SCRIPT

Segmented Momentum Peak

218
Segmented Momentum Peak (SMP) by Chao Ivans

This indicator builds an adaptive momentum threshold by collecting peak and trough readings from a series of past time segments and averaging them into a reference. A current move is treated as significant only when it matches or exceeds what the instrument has historically been capable of producing.

Calculation

The process runs in four stages.

First, Rate of Change is measured on closing prices over a defined period. This value feeds everything that follows.

Second, the chart is divided into segments of a set length. From each segment, one highest reading and one lowest reading is taken. This repeats across the chosen number of segments, gathering a collection of peak samples and trough samples spanning a substantial stretch of history.

Third, all peak samples are averaged into an upper reference and all trough samples into a lower reference. Both are then divided by the sensitivity parameter to produce the working thresholds drawn on the panel.

Fourth, the system counts how many times ROC has broken those thresholds within a recent window of bars. A signal appears only when the count meets the required quota and the current bar is breaking as well.

Logic Behind the Formula

The approach used here is known as block maxima, where extreme values are drawn from each block of data and their distribution is studied. Peaks are used rather than a plain average because averaging every reading would be dominated by the far more numerous quiet bars, dragging the threshold too low and flooding the chart with signals. Collecting only peaks produces a threshold that reflects how strong a move the market has genuinely been capable of delivering.

A useful consequence is that the threshold is self scaling across instruments. On a sluggish asset it settles low on its own. On a volatile asset it rises accordingly. No recalibration is needed when switching markets.

The cluster counting layer exists because a single threshold break is often nothing more than a momentary spike. When real pressure enters, breaks tend to arrive repeatedly within a short span. The quota requirement is what separates the two.

Function

The indicator identifies momentum that is statistically unusual relative to the instrument's own history, then filters it further through a repetition requirement. The output is a directional marker on the main chart whenever buying or selling pressure is confirmed as sustained.

How to Use

The lower panel shows three elements. Columns represent the ROC reading, turning green when breaking the upper threshold, red when breaking the lower threshold, and grey when sitting between them. Two thick lines represent the adaptive thresholds, which shift as volatility conditions change.

Pay attention to the threshold line colours. A blue upper line and a purple lower line indicate the thresholds sit at a meaningful level, so any break carries weight. A black line warns that the threshold has collapsed to a very low level, which typically happens in thin or dormant markets. Breaks come easily under those conditions but signify little, so signals should be ignored or treated with caution.

A green triangle below the bar marks a confirmed cluster of buying pressure. A red triangle above the bar marks selling pressure. These triangles are pressure markers, not entry commands. Use them to confirm a plan already built from price structure rather than as a standalone reason to open a position.

Tuning Guide

Start with sensitivity. If signals feel too scarce, raise it gradually. If the chart gets crowded, lower it.

Segment Length shapes the character of the threshold. Small values give a nimble threshold that tracks current conditions. Large values give one that only shifts when volatility changes on a broad scale.

Number of Segments Sampled controls stability. A large sample count makes the threshold resistant to one or two extreme events, but also slower to adapt when the market regime turns.

Cluster Window and Minimum Hits work as a pair. A narrow window with a high quota demands tightly packed pressure and produces the fewest but firmest signals. A wide window with a low quota is permissive and produces more.

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.