mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-04 20:17:43 +00:00
24e86d762a
- Updated BBWN, BBWP, CCV, CV, CVI, EWMA, GKV, HLV, HV, Jvolty, JVOLTYN, MASSI, NATR, RSV, RV, RVI, TR, UI, VOV, VR, YZV indicators with documentation links. - Added documentation links for Aberration, Acceleration Bands, Andrews' Pitchfork, Adaptive Price Zone, ATR Bands, Bollinger Bands, Center of Gravity, Donchian Channels, Decay Min-Max Channel, Detrended Synthetic Price, EACP, EBSW, HOMOD, Jurik Volatility Bands, Keltner Channel, MA Envelope, Min-Max Channel, Price Channel, Regression Channels, Standard Deviation Channel, Stoller Average Range Channel, Super Trend Bands, Ultimate Bands, Ultimate Channel, VWAP Bands, and VWAP with Standard Deviation Bands.
47 lines
1.4 KiB
Plaintext
47 lines
1.4 KiB
Plaintext
// 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
|
|
//@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)
|