mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-06 04:57:44 +00:00
86fe32a682
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
935 B
Plaintext
29 lines
935 B
Plaintext
// The MIT License (MIT)
|
|
// © mihakralj
|
|
//@version=6
|
|
indicator("Logarithmic Transformation (LOG)", "Logtrans", overlay=false)
|
|
|
|
//@function Applies a natural logarithmic transformation (y = ln(x)) to the input series.
|
|
//@doc https://github.com/mihakralj/pinescript/blob/main/indicators/numerics/log.md
|
|
//@param source series float The input series to transform. Must contain positive values.
|
|
//@returns series float The logarithmically transformed series. Returns na if source <= 0.
|
|
//@optimized for performance and dirty data
|
|
logT(series float source) =>
|
|
if na(source)
|
|
runtime.error("Parameter 'source' cannot be na.")
|
|
if source <= 0
|
|
na
|
|
else
|
|
math.log(source)
|
|
|
|
// ---------- Main loop ----------
|
|
|
|
// Inputs
|
|
i_source = input(close, "Source")
|
|
|
|
// Calculation
|
|
transformedSource = logT(i_source)
|
|
|
|
// Plot
|
|
plot(transformedSource, "Log Transformation", color=color.green, color=color.yellow, linewidth=2)
|