mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-09 14:30:56 +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.
25 lines
756 B
Plaintext
25 lines
756 B
Plaintext
// The MIT License (MIT)
|
|
// © mihakralj
|
|
//@version=6
|
|
indicator("Rectified Linear Unit (ReLU)", "ReLU", overlay=false, precision=6)
|
|
|
|
//@function Applies the Rectified Linear Unit (ReLU) activation function to a series.
|
|
// ReLU returns the input directly if it is positive, otherwise, it returns zero.
|
|
//@param src The source series.
|
|
//@returns The ReLU transformed series.
|
|
relu(series float src) =>
|
|
math.max(0, src)
|
|
|
|
// ---------- Main loop ----------
|
|
|
|
// Inputs
|
|
i_source = input.source(close, "Source")
|
|
|
|
// Calculation of relu on SMA(source)-source
|
|
reluDn = -relu(ta.sma(i_source,20)-i_source)
|
|
reluUp = relu(i_source-ta.sma(i_source,20))
|
|
|
|
// Plot
|
|
plot(reluUp, "ReLU", color=color.green, linewidth=2)
|
|
plot(reluDn, "ReLU", color=color.red, linewidth=2)
|