Stochastic Momentum Index SMI
The close's distance from the middle of the recent high-low range, smoothed twice and divided by half that range smoothed the same way, ×100, with a signal line: a stochastic centred on zero.
It measures where the close sits in its recent range, centred on zero.
01The study, live
Computed by Bentrix’s own code over the same synthetic bars on every page — an illustration of how the study behaves, not a market.
What this figure shows
The figure is computed over 300 sample bars. SMI has no value on the first 45 — the bars it needs before it can answer — and its first value stands on bar 46. Its line runs between -81.50 and 81.58 on these bars, and the last value is 45.37. Counting the conditions the study declares on these bars: crosses above -40 once; crosses below -40 once; crosses above 0 twice; crosses below 0 twice; crosses above 40 3 times; crosses below 40 3 times; crosses above its signal line 11 times; crosses below its signal line 12 times. Press a condition under the figure to see each place marked. As states rather than moments: is above -40 on 153 bars; is below -40 on 102 bars; is above 0 on 119 bars; is below 0 on 136 bars; is above 40 on 93 bars; is below 40 on 162 bars.
02Its parts, named
03What you see
A line in its own pane between −100 and +100 with a signal line. Above zero, the close stands in the upper half of the recent range; below zero, the lower half.
04Where it comes from
William Blau introduced the Stochastic Momentum Index in 1993. Where George Lane's Stochastic measures the close against the low of the range, Blau measured it against the range's midpoint and smoothed both parts twice, so the line centres on zero and moves more smoothly.
05The formula
Over bars, the distance of the close from the range's midpoint, double-smoothed, over half the range, double-smoothed:
M = C − (max (H)_q + min (L)_q)/2, R = max (H)_q − min (L)_q
SMI = 100 · (EMA(EMA(M, r), s))/(1/2 EMA(EMA(R, r), s))
06A worked example
The sample bars used here are eight: closes 20, 21, 23, 22, 24, 25, 24, 26; highs 21, 22, 24, 24, 25, 26, 26, 27; lows 18, 19, 20, 21, 21, 23, 23, 23; opens 19, 20, 21, 23, 22, 24, 25, 24.
Take a window of 5. Over the last five bars the highest high is 27 and the lowest low 21: the midpoint is 24.0 and the width 6. The close is 26.
- distance from the midpoint: 26 − 24.0 = +2.0
- half the width: 6 / 2 = 3.0
Unsmoothed, the index would be 100 × 2.0 / 3.0 = 66.7: the close is two thirds of the way from the middle of the range to its top. The ordinary stochastic on the same bars reads 83.3 — the same position, measured from the bottom on a 0–100 scale.
The SMI then smooths the distance and the half-width separately, twice each, and divides the results: 100 × smoothed distance / smoothed half-width.
With a window of 3 and both smoothings at 2 — the shortest the study takes — the SMI on these bars reads 42.32 on the last bar and its signal, a 2-bar average of it, 43.06.
07Built in Assay
The same study written in Assay, Bentrix’s script language, and drawn by Bentrix itself as the script’s graph: each block is one step of the formula. On the ladder the steps stand in the script’s order, one a row; on the board each wire carries a value from the block that gives it to the block that reads it, left to right. The script computes exactly what the study computes — Bentrix checks the two against each other, candle by candle.
//@version=6 indicator("Stochastic Momentum Index") length = input.int(13, "Length") fastLength = input.int(2, "Fast") slowLength = input.int(25, "Slow") signalLength = input.int(9, "Signal") highest = ta.highest(high, length) lowest = ta.lowest(low, length) // Where the close stands against the middle of the window's range, and how wide that range is. distance = close - (highest + lowest) * 0.5 width = highest - lowest // Both smoothed twice: first slowly, then quickly. smoothDistance = ta.ema(ta.ema(distance, slowLength), fastLength) smoothWidth = ta.ema(ta.ema(width, slowLength), fastLength) // The distance as a percentage of half the range: +100 at the top of the range, -100 at its bottom. smi = na(smoothWidth) ? na : 0.5 * smoothWidth > 0 ? 100 * smoothDistance / (0.5 * smoothWidth) : 0.0 signal = ta.ema(smi, signalLength) plot(na(signal) ? na : smi, "SMI") plot(signal, "Signal") hline(40) hline(-40)
Paste it into the Assay IDE to put it on a chart, or to change it. Looking at the graph is free in every package; editing it as blocks is Plus.
08Readings — what traders look for
Above +40, below −40. Commonly read as the close sitting persistently near the top or bottom of its recent range.
Crossing zero. Read as the close moving from one half of the range to the other.
Crossing its signal. Read as the smoothed position turning.
How the ±40 readings fail. Blau's levels. In a strong trend the line stays at one end of its scale for a long time; a reading there describes the trend and does not mark its end.
How the signal crossing fails. In a market without direction the two lines cross every few bars and most crossings are followed by nothing. The smoothing makes them fewer than a stochastic's, and later.
09In different markets and timeframes
The Stochastic Momentum Index measures the close against the middle of its range and smooths twice; it is a calmer stochastic centred on zero.
It suits markets that swing inside a band; in a trend it stays beyond +40 or below −40 for long stretches and its signal crossings there mark pauses. With 13 bars for the range and two smoothings it covers about three weeks of daily bars and reacts a few bars after the stochastic of the same window. On M1 the range of 13 bars is often only a few points wide, and the line is moved by the spread as much as by the market.
10With other studies
Read with its signal, and beside the Stochastic Oscillator of the same window.
11What it does not tell you
It describes where the close stood within recent ranges, smoothed; it says nothing of the next bar. In a steady trend it can stay near an extreme for a long time.
12Inputs and defaults
- 1Time Period — 13Period of the high/low range
- 2Fast Period — 2Period of the second smoothing, applied to the first
- 3Slow Period — 25Period of the first smoothing, applied to the raw momentum
- 4Signal Period — 9Smoothing for the signal line (period length)
- 5Timeframe — ChartThe chart's own by default; any higher one, read on the last closed candle. A finer one is never offered.
- 6Wait for the candle to close — OnThe value of a higher timeframe is taken only from a candle that has finished.
What each input changes
- Time PeriodThe number of bars in the window. Longer: steadier and later. Shorter: quicker and noisier.
- Fast PeriodThe second, short EMA (2).
- Slow PeriodThe first, long EMA (25).
- Signal PeriodThe EMA of the index drawn beside it (9).
- In use13, 25, 2 and a signal of 9 here; Blau's levels are ±40.
13Limits and common misreadings
Not the Stochastic's scale. Its zero is the Stochastic's 50; its ±40 are not the Stochastic's 20 and 80.
Three periods. The range length and both smoothings change it a great deal.
14Conditions an alert or a strategy can watch
an event happens on one bar a state holds on every bar while it lasts
These are the conditions the study itself declares — the same rules the alert editor and the strategy engine read, and the ones the figure's chips show.
15Practise it in the laboratory
Attach SMI and Stochastic with the same range length. Step through a day and note how often the Stochastic crossed 50 while SMI stayed on one side of zero.
Open the laboratory17In Bentrix
- From the menu: a chart's Indicators button › Oscillators › SMI, or type SMI in its search.
- Its settings: the settings card opens when it is added; its legend's name opens it again.
18From an agent or a program
Two tools reach it. study_values computes it over a workbench’s candles up to the clock — no chart needed — and study_attach puts it on a chart, where it is drawn and saved with the chart ({"chart": "<chart uri>", "kind": "smi"}).
The study, as a chart files it
This is a new SMI’s entry — its kind, its calculation, the price it reads and its settings. Change a setting here to read it with other inputs.
{
"applied": "close",
"convention": "talib",
"kind": "smi",
"settings": {
"shape": "ta",
"values": {
"optInFastPeriod": 2.0,
"optInSignalPeriod": 9.0,
"optInSlowPeriod": 25.0,
"optInTimePeriod": 13.0
}
}
}An agent
An agent calls the MCP tool with it:
{
"name": "study_values",
"arguments": {
"bench": "bentrix://lab/\u2026/bench/\u2026",
"symbol": "EURUSD",
"timeframe": "H1",
"limit": 5,
"study": {
"applied": "close",
"convention": "talib",
"kind": "smi",
"settings": {
"shape": "ta",
"values": {
"optInFastPeriod": 2.0,
"optInSignalPeriod": 9.0,
"optInSlowPeriod": 25.0,
"optInTimePeriod": 13.0
}
}
}
}
}A program
A program does the same in its language — bench and market as in the built-in indicators guide:
Python
values = client.study.values(bench, market, "H1", {"applied": "close", "convention": "talib", "kind": "smi", "settings": {"shape": "ta", "values": {"optInFastPeriod": 2.0, "optInSignalPeriod": 9.0, "optInSlowPeriod": 25.0, "optInTimePeriod": 13.0}}}, limit=5)
print("times:", values["times"])
for line in values["lines"]:
print("line:", line["line"])
print(" newest values:", line["values"])JavaScript
const values = await client.study.values({ bench, symbol: market, timeframe: "H1", study: { "applied": "close", "convention": "talib", "kind": "smi", "settings": { "shape": "ta", "values": { "optInFastPeriod": 2.0, "optInSignalPeriod": 9.0, "optInSlowPeriod": 25.0, "optInTimePeriod": 13.0 } } }, limit: 5 });
console.log("times:", values.times);
for (const line of values.lines) {
console.log("line:", line.line);
console.log(" newest values:", line.values);
}C#
var values = await client.Study.Values(bench, market, "H1", new Dictionary<string, object?> { ["applied"] = "close", ["convention"] = "talib", ["kind"] = "smi", ["settings"] = new Dictionary<string, object?> { ["shape"] = "ta", ["values"] = new Dictionary<string, object?> { ["optInFastPeriod"] = 2.0, ["optInSignalPeriod"] = 9.0, ["optInSlowPeriod"] = 25.0, ["optInTimePeriod"] = 13.0 } } }, limit: 5);
Console.WriteLine($"times: {values!["times"]!}");
foreach (var line in values!["lines"]!.AsArray())
{
Console.WriteLine($"line: {line!["line"]!}");
Console.WriteLine($" newest values: {line!["values"]!}");
}Go
values := must(client.Study.Values(ctx, mcp.StudyValuesArgs{Bench: bench, Symbol: market, Timeframe: "H1", Study: map[string]any{"applied": "close", "convention": "talib", "kind": "smi", "settings": map[string]any{"shape": "ta", "values": map[string]any{"optInFastPeriod": 2.0, "optInSignalPeriod": 9.0, "optInSlowPeriod": 25.0, "optInTimePeriod": 13.0}}}, Limit: mcp.Ptr[int64](5)}))
fmt.Println("times:", at(values, "times"))
for _, line := range at(values, "lines").([]any) {
fmt.Println("line:", at(line, "line"))
fmt.Println(" newest values:", at(line, "values"))
}Java
Object values = client.study.values(new Bentrix.StudyApi.ValuesArgs(bench, market, "H1", obj("applied", "close", "convention", "talib", "kind", "smi", "settings", obj("shape", "ta", "values", obj("optInFastPeriod", 2.0, "optInSignalPeriod", 9.0, "optInSlowPeriod", 25.0, "optInTimePeriod", 13.0)))).limit(5L));
System.out.println("times:" + " " + at(values, "times"));
for (Object line : (List<Object>) at(values, "lines")) {
System.out.println("line:" + " " + at(line, "line"));
System.out.println(" newest values:" + " " + at(line, "values"));
}C++
auto values = client.study.values_(StudyApi::ValuesArgs(bench, market, "H1", Json::Object{{"applied", "close"}, {"convention", "talib"}, {"kind", "smi"}, {"settings", Json::Object{{"shape", "ta"}, {"values", Json::Object{{"optInFastPeriod", 2.0}, {"optInSignalPeriod", 9.0}, {"optInSlowPeriod", 25.0}, {"optInTimePeriod", 13.0}}}}}}).limit(5));
std::cout << "times:" << " " << values["times"].dump() << std::endl;
for (const Json &line : values["lines"].arr()) {
std::cout << "line:" << " " << line["line"].dump() << std::endl;
std::cout << " newest values:" << " " << line["values"].dump() << std::endl;
}Julia
values = client.study.values(bench, market, "H1", Dict{String,Any}("applied" => "close", "convention" => "talib", "kind" => "smi", "settings" => Dict{String,Any}("shape" => "ta", "values" => Dict{String,Any}("optInFastPeriod" => 2.0, "optInSignalPeriod" => 9.0, "optInSlowPeriod" => 25.0, "optInTimePeriod" => 13.0))); limit = 5)
println("times:", " ", values["times"])
for line in values["lines"]
println("line:", " ", line["line"])
println(" newest values:", " ", line["values"])
endR
values <- client$study$values(bench, market, "H1", list(applied = "close", convention = "talib", kind = "smi", settings = list(shape = "ta", values = list(optInFastPeriod = 2.0, optInSignalPeriod = 9.0, optInSlowPeriod = 25.0, optInTimePeriod = 13.0))), limit = 5)
cat("times:", format(values$times), "\n")
for (line in values$lines) {
cat("line:", format(line$line), "\n")
cat(" newest values:", format(line$values), "\n")
}Rust
let values = client.study().values(mcp::StudyValuesArgs::new(bench.clone(), market.clone(), "H1", serde_json::json!({"applied": "close", "convention": "talib", "kind": "smi", "settings": {"shape": "ta", "values": {"optInFastPeriod": 2.0, "optInSignalPeriod": 9.0, "optInSlowPeriod": 25.0, "optInTimePeriod": 13.0}}})).limit(5))?;
println!("times: {}", values["times"]);
for line in values["lines"].as_array().into_iter().flatten() {
println!("line: {}", line["line"]);
println!(" newest values: {}", line["values"]);
}Reading the answer
times— the candles’ open times, in milliseconds since 1970 (UTC), oldest first.lines— one entry per line, in this order, each with itslinename and itsvalues;values[i]belongs to the candle attimes[i].- The last value is the candle at the clock’s, which may still be forming: it changes until that candle closes, as on the chart. Nothing after the clock is ever computed.
nullis a candle with no value yet — the warm-up, about 1 × the period at the start of the history.- Its fixed levels, drawn on the chart:
[-40.0, 0.0, 40.0].
line | What it is |
|---|---|
Main | the indicator's own value |
Signal | a smoothing of the main line, drawn beside it |
In a strategy
Filed under a key of your choice in a strategy document’s studies — here smi: {"smi": {"applied": "close", "convention": "talib", "kind": "smi", "settings": {"shape": "ta", "values": {"optInFastPeriod": 2.0, "optInSignalPeriod": 9.0, "optInSlowPeriod": 25.0, "optInTimePeriod": 13.0}}}} — its rules can name:
| Write | What it is |
|---|---|
smi | its main line, as a value in a compare |
smi.signal | this line, as a value in a compare |
{"cond": "smi:level.cross_up:-40"} | a condition it declares itself |
{"cond": "smi:level.cross_down:-40"} | a condition it declares itself |
{"cond": "smi:level.above:-40"} | a condition it declares itself |
{"cond": "smi:level.below:-40"} | a condition it declares itself |
{"cond": "smi:level.cross_up:0"} | a condition it declares itself |
{"cond": "smi:level.cross_down:0"} | a condition it declares itself |
{"cond": "smi:level.above:0"} | a condition it declares itself |
{"cond": "smi:level.below:0"} | a condition it declares itself |
{"cond": "smi:level.cross_up:40"} | a condition it declares itself |
{"cond": "smi:level.cross_down:40"} | a condition it declares itself |
{"cond": "smi:level.above:40"} | a condition it declares itself |
{"cond": "smi:level.below:40"} | a condition it declares itself |
{"cond": "smi:signal.cross_up"} | a condition it declares itself |
{"cond": "smi:signal.cross_down"} | a condition it declares itself |
{"cond": "smi:signal.above"} | a condition it declares itself |
{"cond": "smi:signal.below"} | a condition it declares itself |
19Sources
- Blau, William. "Stochastic Momentum." Technical Analysis of Stocks & Commodities, January 1993.
- Blau, William. Momentum, Direction, and Divergence. Wiley, 1995.
Bentrix 0.1.382Every number, name and default on these pages is read from the application itself.What is comingWhat changed