mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-15 17:18:05 +00:00
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat> Co-authored-by: Warp <agent@warp.dev>
29 lines
919 B
Plaintext
29 lines
919 B
Plaintext
// The MIT License (MIT)
|
|
// © mihakralj
|
|
//@version=6
|
|
indicator("Square Root Transformation (SQRT)", "Sqrttrans", overlay=false)
|
|
|
|
//@function Applies a square root transformation (y = √x) to the input series.
|
|
//@doc https://github.com/mihakralj/pinescript/blob/main/indicators/numerics/sqrt.md
|
|
//@param source series float The input series to transform. Must contain non-negative values.
|
|
//@returns series float The square root transformed series. Returns na if source < 0.
|
|
//@optimized for performance and dirty data
|
|
sqrtT(series float source) =>
|
|
if na(source)
|
|
runtime.error("Parameter 'source' cannot be na.")
|
|
if source < 0
|
|
na
|
|
else
|
|
math.sqrt(source)
|
|
|
|
// ---------- Main loop ----------
|
|
|
|
// Inputs
|
|
i_source = input(close, "Source")
|
|
|
|
// Calculation
|
|
transformedSource = sqrtT(i_source)
|
|
|
|
// Plot
|
|
plot(transformedSource, "Square Root Transformation", color=color.yellow, linewidth=2)
|