mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-06 13:07:44 +00:00
24e86d762a
- Updated BBWN, BBWP, CCV, CV, CVI, EWMA, GKV, HLV, HV, Jvolty, JVOLTYN, MASSI, NATR, RSV, RV, RVI, TR, UI, VOV, VR, YZV indicators with documentation links. - Added documentation links for Aberration, Acceleration Bands, Andrews' Pitchfork, Adaptive Price Zone, ATR Bands, Bollinger Bands, Center of Gravity, Donchian Channels, Decay Min-Max Channel, Detrended Synthetic Price, EACP, EBSW, HOMOD, Jurik Volatility Bands, Keltner Channel, MA Envelope, Min-Max Channel, Price Channel, Regression Channels, Standard Deviation Channel, Stoller Average Range Channel, Super Trend Bands, Ultimate Bands, Ultimate Channel, VWAP Bands, and VWAP with Standard Deviation Bands.
28 lines
991 B
Plaintext
28 lines
991 B
Plaintext
// The MIT License (MIT)
|
|
// © mihakralj
|
|
//@version=6
|
|
indicator("Logistic Function (SIGMOID)", "SIGMOID", overlay=false, precision=6)
|
|
|
|
//@function Applies the logistic (sigmoid) function to a source series.
|
|
// Formula: S(x) = 1 / (1 + exp(-k * (x - x0)))
|
|
// Maps any real-valued input to the range (0, 1).
|
|
//@param src The source series.
|
|
//@param k The steepness factor of the sigmoid curve. Higher k means a steeper curve.
|
|
//@param x0 The x-value of the sigmoid's midpoint (where the output is 0.5).
|
|
//@returns The sigmoid transformed series, values between 0 and 1.
|
|
sigmoid(series float src, simple float k, float x0) =>
|
|
1 / (1 + math.exp(-k * (src - x0)))
|
|
|
|
// ---------- Main loop ----------
|
|
|
|
// Inputs
|
|
i_source = input.source(close, "Source")
|
|
i_steepness_k = input.float(0.5, "Steepness (k)", minval = 0.000001, step = 0.1)
|
|
|
|
// Calculation
|
|
sigmoidValue = sigmoid(i_source, i_steepness_k, ta.sma(i_source,200))
|
|
|
|
// Plot
|
|
plot(sigmoidValue, "Sigmoid", color=color.yellow, linewidth=2)
|
|
|