// Licensed under the Apache License, Version 2.0 // © 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)