Bentrix Docs
HomePricingDashboard

Fast Stochastic Oscillator (Stochastic Fast)

Oscillatorsoscillator2 linesin every package

Fast Stochastic — %K without the slowing step, plus its %D average.

It measures the same position within the recent range as the Stochastic, one smoothing stage earlier. Read the same way, and expect it to reach the extremes more often and hold them for less time.

01The study, live

Live figureScroll to zoom, drag the bars to pan.
2080
bar —O — H — L — C —main line —signal —first value at —
Show where:

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. Stochastic Fast has no value on the first 6 — the bars it needs before it can answer — and its first value stands on bar 7. Its line runs between 0.0726 and 99.73 on these bars, and the last value is 41.27. The pane's scale is fixed at 0 to 100, the range the study can take. Counting the conditions the study declares on these bars: crosses above 20 31 times; crosses below 20 31 times; crosses above 80 26 times; crosses below 80 27 times; crosses above its signal line 61 times; crosses below its signal line 61 times. Press a condition under the figure to see each place marked. As states rather than moments: is above 20 on 221 bars; is below 20 on 73 bars; is above 80 on 67 bars; is below 80 on 227 bars; is above its signal line on 146 bars; is below its signal line on 148 bars.

02Its parts, named

The bars it readseach bar's open, high, low and closeWarm-upno value on the first 6 bars: thestudy needs them before it cananswerThe second linedrawn with the main line: its signalor its partnerLevel 80a fixed reference the study is readagainstThe main linethe study's own value on each barLevel 20a fixed reference the study is readagainst
Computed by Bentrix’s own code over the sample bars. It is drawn on once, as you reach the figure.

03What you see

Stochastic Fast is two lines in a pane of its own, between 0 and 100: %K, the close's position within the high–low range of the last bars, and %D, an average of %K. It is the Stochastic Oscillator without the slowing step, so both lines are quicker and more jagged.

04Where it comes from

Credited to George C. Lane, who taught and wrote about it from the 1950s on. Its idea: in a rise, closes tend to sit near the top of the recent range; in a fall, near the bottom.

05The formula

%Kfast=100·Ct−min(LN)max(HN)−min(LN)

over the last N bars (5 by default). This raw value is the line drawn as %K — the Fast Stochastic has no slowing step — and %D is an average of it over 3 bars by default:

%D=MA(%Kfast, 3)
Ctthe close
max(HN), min(LN)the highest high and the lowest low of the last N bars
MA(x,3)the chosen average of x over 3 bars

a simple average unless another kind is chosen.

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 %K period 5. On the last bar the highest high of the last five bars is 27 and the lowest low 21; the close is 26.

Raw %K = (26 − 21) / (27 − 21) × 100 = 83.33

The close sits 83 % of the way up the five-bar range. The same step on the two bars before gives 85.71 and 66.67.

The fast stochastic draws that raw value as %K, with no slowing. The Fast Stochastic's %D is the average of the last three: (85.71 + 66.67 + 83.33) / 3 = 78.57 — which is exactly the %K that the Stochastic Oscillator draws with Slowing 3, where the Fast Stochastic draws it as %D.

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.

THE SCRIPT’S GRAPH
//@version=6
indicator("Fast Stochastic")
kLength = input.int(5, "%K length")
dLength = input.int(3, "%D length")
lowest = ta.lowest(low, kLength)
highest = ta.highest(high, kLength)
// Where the close stands in the window's range, 0 to 100 — with no slowing.
k = na(highest) ? na : highest - lowest != 0 ? (close - lowest) / (highest - lowest) * 100 : 0.0
d = ta.sma(k, dLength)
plot(na(d) ? na : k, "%K")
plot(d, "%D")
hline(80)
hline(20)

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 80, below 20 are read as the close sitting near the top, or the bottom, of the recent range.

%K crossing %D is read as the position within the range changing direction.

Crosses inside an extreme zone — %K crossing below %D above 80 — are read by many traders as the close starting to slip from the top of its range.

Divergence with price, as with the RSI.

How the readings fail. The fast version is the raw placement of the close in its range, so it reaches 0 and 100 often and crosses its %D constantly. In a strong trend the line stays at one end of its scale for a long time; a high reading there describes the trend and does not mark its end.

09In different markets and timeframes

The fast stochastic is the raw measurement and suits a reader who wants the earliest turn and accepts the noise. In a range it reaches both ends within a few bars; in a trend it pins at one end like the slow version, only more jaggedly.

10With other studies

Read beside the slow Stochastic Oscillator of the same window — the fast %D is the slow %K — and beside a trend filter.

11What it does not tell you

!

It says where the close stands within the range of the last few bars and nothing about how wide that range is: a reading of 95 in a range of ten points and one in a range of a thousand are the same number. Being the raw form, it also says it with all the noise the slow version removes.

12Inputs and defaults

Stochastic Fast (3, 5)settings card
1%D period3
2%K period5
3AverageThe study's own
4TimeframeChart
5Wait for the candle to closeOn
  1. 1
    %D period — 3The smoothing of %K that makes the second line.
  2. 2
    %K period — 5The window of highs and lows the close is placed within.
  3. 3
    Average — The study's ownThe kind of moving average inside the study. Left at the study's own, it is the one the study's calculation uses by itself.
  4. 4
    Timeframe — ChartThe chart's own by default; any higher one, read on the last closed candle. A finer one is never offered.
  5. 5
    Wait for the candle to close — OnThe value of a higher timeframe is taken only from a candle that has finished.

What each input changes

  • AverageThe kind of average %D is. Left at the study's own it is a simple average of %K; an exponential one follows %K more closely.
  • In use5 and 3 by default; 14 and 3 are common. The %K window is the range the close is placed in.

13Limits and common misreadings

Short settings make it very fast and noisy; on most markets it changes direction many times a day on M5.

14Conditions an alert or a strategy can watch

crosses above 20 eventcrosses below 20 eventis above 20 stateis below 20 statecrosses above 80 eventcrosses below 80 eventis above 80 stateis below 80 statecrosses above its signal line eventcrosses below its signal line eventis above its signal line stateis below its signal line state

Event: the bar it happens on an event happens on one barState: every bar while it holds 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

Put the fast and the slow Stochastic (5, 3, 3) in two panes on one chart and replay a range. Check on a few bars that the fast %D and the slow %K are the same line, and count the crossings each pane shows.

Open the laboratory

17In Bentrix

  • From the menu: a chart's Indicators button › Oscillators › Stochastic Fast, or type Stochastic Fast 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": "stoch_f"}).

The study, as a chart files it

This is a new Stochastic Fast’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": "stoch_f",
  "settings": {
    "d": 3,
    "k": 5,
    "shape": "stoch_f"
  }
}

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": "stoch_f",
      "settings": {
        "d": 3,
        "k": 5,
        "shape": "stoch_f"
      }
    }
  }
}

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": "stoch_f", "settings": {"d": 3, "k": 5, "shape": "stoch_f"}}, limit=5)
print("times:", values["times"])
for line in values["lines"]:
    print("line:", line["line"])
    print("  newest values:", line["values"])

JSJavaScript

const values = await client.study.values({ bench, symbol: market, timeframe: "H1", study: { "applied": "close", "convention": "talib", "kind": "stoch_f", "settings": { "d": 3, "k": 5, "shape": "stoch_f" } }, 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#C#

var values = await client.Study.Values(bench, market, "H1", new Dictionary<string, object?> { ["applied"] = "close", ["convention"] = "talib", ["kind"] = "stoch_f", ["settings"] = new Dictionary<string, object?> { ["d"] = 3, ["k"] = 5, ["shape"] = "stoch_f" } }, 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"]!}");
}

GOGo

values := must(client.Study.Values(ctx, mcp.StudyValuesArgs{Bench: bench, Symbol: market, Timeframe: "H1", Study: map[string]any{"applied": "close", "convention": "talib", "kind": "stoch_f", "settings": map[string]any{"d": 3, "k": 5, "shape": "stoch_f"}}, 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", "stoch_f", "settings", obj("d", 3, "k", 5, "shape", "stoch_f"))).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++C++

auto values = client.study.values_(StudyApi::ValuesArgs(bench, market, "H1", Json::Object{{"applied", "close"}, {"convention", "talib"}, {"kind", "stoch_f"}, {"settings", Json::Object{{"d", 3}, {"k", 5}, {"shape", "stoch_f"}}}}).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" => "stoch_f", "settings" => Dict{String,Any}("d" => 3, "k" => 5, "shape" => "stoch_f")); limit = 5)
println("times:", " ", values["times"])
for line in values["lines"]
    println("line:", " ", line["line"])
    println("  newest values:", " ", line["values"])
end

RR

values <- client$study$values(bench, market, "H1", list(applied = "close", convention = "talib", kind = "stoch_f", settings = list(d = 3, k = 5, shape = "stoch_f")), 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")
}

RRust

let values = client.study().values(mcp::StudyValuesArgs::new(bench.clone(), market.clone(), "H1", serde_json::json!({"applied": "close", "convention": "talib", "kind": "stoch_f", "settings": {"d": 3, "k": 5, "shape": "stoch_f"}})).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 its line name and its values; values[i] belongs to the candle at times[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.
  • null is 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: [20.0, 80.0].
lineWhat it is
Mainthe indicator's own value
Signala 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 stoch_f: {"stoch_f": {"applied": "close", "convention": "talib", "kind": "stoch_f", "settings": {"d": 3, "k": 5, "shape": "stoch_f"}}} — its rules can name:

WriteWhat it is
stoch_fits main line, as a value in a compare
stoch_f.signalthis line, as a value in a compare
{"cond": "stoch_f:level.cross_up:20"}a condition it declares itself
{"cond": "stoch_f:level.cross_down:20"}a condition it declares itself
{"cond": "stoch_f:level.above:20"}a condition it declares itself
{"cond": "stoch_f:level.below:20"}a condition it declares itself
{"cond": "stoch_f:level.cross_up:80"}a condition it declares itself
{"cond": "stoch_f:level.cross_down:80"}a condition it declares itself
{"cond": "stoch_f:level.above:80"}a condition it declares itself
{"cond": "stoch_f:level.below:80"}a condition it declares itself
{"cond": "stoch_f:signal.cross_up"}a condition it declares itself
{"cond": "stoch_f:signal.cross_down"}a condition it declares itself
{"cond": "stoch_f:signal.above"}a condition it declares itself
{"cond": "stoch_f:signal.below"}a condition it declares itself

19Sources

  1. Murphy, John J. Technical Analysis of the Financial Markets. New York Institute of Finance, 1999, ch. 10.
  2. Colby, Robert W. The Encyclopedia of Technical Market Indicators, 2nd ed. McGraw-Hill, 2003, "Stochastics".

Bentrix 0.1.382Every number, name and default on these pages is read from the application itself.What is comingWhat changed