mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-22 20:48:04 +00:00
SIMD Refactor: Merge simd-dev into dev (#55)
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>
This commit is contained in:
co-authored by
Claude Opus 4.5
aider
Warp
parent
5bcdf8d614
commit
86fe32a682
@@ -0,0 +1,47 @@
|
||||
// The MIT License (MIT)
|
||||
// © mihakralj
|
||||
//@version=6
|
||||
indicator("Elder's Force Index (EFI)", "EFI", overlay=false)
|
||||
|
||||
//@function Calculates Elder's Force Index (EFI), measuring buying and selling pressure through price change and volume
|
||||
//@doc https://github.com/mihakralj/pinescript/blob/main/indicators/volume/efi.md
|
||||
//@param len Lookback period for EMA smoothing (default: 13)
|
||||
//@param src Source price for calculation (default: built-in close)
|
||||
//@param src_vol The volume (default: built-in volume)
|
||||
//@returns float The smoothed Force Index value
|
||||
efi(len = 13, src = close, src_vol = volume) =>
|
||||
if len < 1
|
||||
runtime.error("Length must be >= 1")
|
||||
var float prev_src = src
|
||||
float raw_force = (nz(src) - nz(prev_src)) * nz(src_vol)
|
||||
prev_src := src
|
||||
float a = 2.0 / (len + 1.0)
|
||||
float beta = 1.0 - a
|
||||
var float ema = na
|
||||
var float result = na
|
||||
var float e = 1.0
|
||||
var bool warmup = true
|
||||
if na(ema)
|
||||
ema := 0
|
||||
result := raw_force
|
||||
else
|
||||
ema := a * (raw_force - ema) + ema
|
||||
if warmup
|
||||
e *= beta
|
||||
float c = 1.0 / (1.0 - e)
|
||||
result := c * ema
|
||||
if e <= 1e-10
|
||||
warmup := false
|
||||
else
|
||||
result := ema
|
||||
result
|
||||
|
||||
|
||||
// ---------- Inputs ----------
|
||||
i_length = input.int(13, "Length", minval=1)
|
||||
|
||||
// ---------- Calculations ----------
|
||||
efi_val = efi(i_length)
|
||||
|
||||
// ---------- Plotting ----------
|
||||
plot(efi_val, "EFI", color=color.yellow, linewidth=2)
|
||||
Reference in New Issue
Block a user