mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-05 12:37:43 +00:00
35a6702b06
Deep review of all indicator categories verified .md headers against .cs WarmupPeriod, parameters, inputs, and outputs. Fixes include warmup corrections, parameter documentation, output type accuracy, and Pine Script alignment.
30 lines
941 B
Plaintext
30 lines
941 B
Plaintext
// Licensed under the Apache License, Version 2.0
|
|
// © mihakralj
|
|
//@version=6
|
|
indicator("Linear Scaling Transformer (LINEARTRANS)", "LINEARTRANS", overlay=true, precision=8)
|
|
|
|
//@function Applies a simple affine (linear) transformation: y = slope * x + intercept
|
|
//@param src Source series to transform
|
|
//@param a Slope (scaling factor). Default 1.0.
|
|
//@param b Intercept (offset). Default 0.0.
|
|
//@returns Linearly transformed value: a * src + b
|
|
//@optimized Single FMA operation per bar — O(1) with zero allocations.
|
|
lineartrans(series float src, float a, float b) =>
|
|
if na(src)
|
|
na
|
|
else
|
|
a * src + b
|
|
|
|
// ---------- Main loop ----------
|
|
|
|
// Inputs
|
|
i_source = input.source(close, "Source")
|
|
i_slope = input.float(1.0, "Slope (a)")
|
|
i_intercept = input.float(0.0, "Intercept (b)")
|
|
|
|
// Calculation
|
|
result = lineartrans(i_source, i_slope, i_intercept)
|
|
|
|
// Plot
|
|
plot(result, "Lineartrans", color=color.yellow, linewidth=2)
|