Stochastic
"Stochastic" by everget, MPL-2.0. Ported to FloScript by FloSignals; modifications under MPL-2.0. Original: Stochastic (v2.0), read 2026-11-15T18:28:50.496Z; source language v4.
Licence: Mozilla Public License 2.0 (MPL-2.0) — full text. The source is published with it, modifications included, under the same licence.
Stochastic by everget, ported from Pine v4. Pane indicator with 3 plots, 2 marker series, 4 fills, 5 levels, bar/background colouring and 13 inputs.
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// (Notice added by FloSignals: the author's source carries none. It was published open-source on 2021-02-11; since 2019-07-26 the platform it was published on has released such a script under MPL-2.0 automatically.)
// Copyright (c) 2021-present, Alex Orekhov (everget)
// ------------------------------------------------------------------------------------------------
// Original author: everget
// Original title: Stochastic
// Licence: MPL-2.0 (the notice above was added by FloSignals; the original carries none)
// Pine version: 4
// Fetched: 2026-11-15
// Ported to FloScript by FloSignals; modifications under MPL-2.0.
// Converter: @flosignals/floscript 0.1.0, strict mode, score 100/100
// ------------------------------------------------------------------------------------------------
//@floscript=1
//@version=5
// Converted by the FloScript converter from a Pine-compatible v4 source.
indicator("Stochastic", shorttitle="Stoch", precision=2)
periodK = input.int(title="K", minval=1, defval=14)
periodD = input.int(title="D", minval=1, defval=3)
smoothK = input.int(title="Smooth", minval=1, defval=3)
src = input.source(title="Source", defval=close)
obLevel = input.int(title="Overbought Level", defval=80)
osLevel = input.int(title="Oversold Level", defval=20)
maxLevel = input.int(title="Max Level", defval=100)
minLevel = input.int(title="Min Level", defval=0)
showHistogram = input.bool(title="Show Histogram ?", defval=false)
highlightBreakouts = input.bool(title="Highlight Overbought/Oversold Breakouts ?", defval=true)
highlightCrossovers = input.bool(title="Highlight K/D Crossovers ?", defval=true)
highlightMiddleCrossovers = input.bool(title="Highlight Middle Line Crossovers ?", defval=true)
applyRibbonFilling = input.bool(title="Apply Ribbon Filling ?", defval=true)
k = ta.sma(ta.stoch(src, high, low, periodK), smoothK)
d = ta.sma(k, periodD)
trendColor = k > d ? #0ebb23 : color.red
kColor = applyRibbonFilling ? trendColor : #ff3e7d
dColor = applyRibbonFilling ? trendColor : #3c78d8
kPlot = plot(k, title="%K", color=color.new(kColor, 0))
dPlot = plot(d, title="%D", color=color.new(dColor, 0))
hist = k - d
histColor = hist >= 0 ? (hist[1] < hist ? #26A69A : #B2DFDB) : hist[1] < hist ? #FFCDD2 : #EF5350
plot(showHistogram ? hist : na, title="Histogram", style=plot.style_columns, color=color.new(histColor, 0))
var color noneColor = color.new(color.white, 100)
maxLevelPlot = hline(maxLevel, title="Max Level", linestyle=hline.style_dotted, color=noneColor)
obLevelPlot = hline(obLevel, title="Overbought Level", linestyle=hline.style_dotted, color=#00796b)
hline(50, title="Middle Level", linestyle=hline.style_dotted, color=#989898)
osLevelPlot = hline(osLevel, title="Oversold Level", linestyle=hline.style_dotted, color=#f57f17)
minLevelPlot = hline(minLevel, title="Min Level", linestyle=hline.style_dotted, color=noneColor)
fill(obLevelPlot, osLevelPlot, title="Middle Zone", color=color.new(color.purple, 95))
obFillColor = k > obLevel and highlightBreakouts ? color.green : na
osFillColor = k < osLevel and highlightBreakouts ? color.red : na
fill(maxLevelPlot, obLevelPlot, title="Upper Band Breakout", color=color.new(obFillColor, 85))
fill(minLevelPlot, osLevelPlot, title="Lower Band Breakout", color=color.new(osFillColor, 85))
fillColor = applyRibbonFilling ? trendColor : na
fill(kPlot, dPlot, title="Ribbon", color=color.new(fillColor, 70))
middleCrossBgColor = highlightMiddleCrossovers ? (k > 50 ? color.green : color.red) : na
bgcolor(color.new(middleCrossBgColor, 90))
plotshape(highlightCrossovers and ta.crossover(k, d) ? k : na, title="K/D Crossover", location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.green, 0))
plotshape(highlightCrossovers and ta.crossunder(k, d) ? k : na, title="K/D Crossunder", location=location.absolute, style=shape.circle, size=size.tiny, color=color.new(color.red, 0))
This file is under the Mozilla Public License 2.0; it is a port of the original by everget, with the original licence header kept and the changes made for FloScript noted in the file.
- v1
Library refresh 2026-11-15
Disclaimer. Scripts are written and published by members, or ported by FloSignals from open-source originals, and are their authors' own work and opinion. FloSignals does not review them for correctness and nothing in a script is financial advice or a recommendation to buy or sell anything — read the Risk Disclaimer. Posting here is under the Community Rules; a script that is not the poster's to post can be reported as the Copyright & Takedowns page says.

Comments (0)
No comments yet. Members can leave one.