Library "MomentumIndicators" This is a library of 'Momentum Indicators', also denominated as oscillators. The purpose of this library is to organize momentum indicators in just one place, making it easy to access. In addition, it aims to allow customized versions, not being restricted to just the price value. An example of this use case is the popular Stochastic RSI. # Indicators: 1. Relative Strength Index (RSI): Measures the relative strength of recent price gains to recent price losses of an asset. 2. Rate of Change (ROC): Measures the percentage change in price of an asset over a specified time period. 3. Stochastic Oscillator (Stoch): Compares the current price of an asset to its price range over a specified time period. 4. True Strength Index (TSI): Measures the price change, calculating the ratio of the price change (positive or negative) in relation to the absolute price change. The values of both are smoothed twice to reduce noise, and the final result is normalized in a range between 100 and -100. 5. Stochastic Momentum Index (SMI): Combination of the True Strength Index with a signal line to help identify turning points in the market. 6. Williams Percent Range (Williams %R): Compares the current price of an asset to its highest high and lowest low over a specified time period. 7. Commodity Channel Index (CCI): Measures the relationship between an asset's current price and its moving average. 8. Ultimate Oscillator (UO): Combines three different time periods to help identify possible reversal points. 9. Moving Average Convergence/Divergence (MACD): Shows the difference between short-term and long-term exponential moving averages. 10. Fisher Transform (FT): Normalize prices into a Gaussian normal distribution. 11. Inverse Fisher Transform (IFT): Transform the values of the Fisher Transform into a smaller and more easily interpretable scale is through the application of an inverse transformation to the hyperbolic tangent function. This transformation takes the values of the FT, which range from -infinity to +infinity, to a scale limited between -1 and +1, allowing them to be more easily visualized and compared. 12. Premier Stochastic Oscillator (PSO): Normalizes the standard stochastic oscillator by applying a five-period double exponential smoothing average of the %K value, resulting in a symmetric scale of 1 to -1 # Indicators of indicators: ## Stochastic: 1. Stochastic of RSI (Relative Strengh Index) 2. Stochastic of ROC (Rate of Change) 3. Stochastic of UO (Ultimate Oscillator) 4. Stochastic of TSI (True Strengh Index) 5. Stochastic of Williams R% 6. Stochastic of CCI (Commodity Channel Index). 7. Stochastic of MACD (Moving Average Convergence/Divergence) 8. Stochastic of FT (Fisher Transform) 9. Stochastic of Volume 10. Stochastic of MFI (Money Flow Index) 11. Stochastic of On OBV (Balance Volume) 12. Stochastic of PVI (Positive Volume Index) 13. Stochastic of NVI (Negative Volume Index) 14. Stochastic of PVT (Price-Volume Trend) 15. Stochastic of VO (Volume Oscillator) 16. Stochastic of VROC (Volume Rate of Change) ## Inverse Fisher Transform: 1.Inverse Fisher Transform on RSI (Relative Strengh Index) 2.Inverse Fisher Transform on ROC (Rate of Change) 3.Inverse Fisher Transform on UO (Ultimate Oscillator) 4.Inverse Fisher Transform on Stochastic 5.Inverse Fisher Transform on TSI (True Strength Index) 6.Inverse Fisher Transform on CCI (Commodity Channel Index) 7.Inverse Fisher Transform on Fisher Transform (FT) 8.Inverse Fisher Transform on MACD (Moving Average Convergence/Divergence) 9.Inverse Fisher Transfor on Williams R% (Williams Percent Range) 10.Inverse Fisher Transfor on CMF (Chaikin Money Flow) 11.Inverse Fisher Transform on VO (Volume Oscillator) 12.Inverse Fisher Transform on VROC (Volume Rate of Change) ## Stochastic Momentum Index: 1.Stochastic Momentum Index of RSI (Relative Strength Index) 2.Stochastic Momentum Index of ROC (Rate of Change) 3.Stochastic Momentum Index of VROC (Volume Rate of Change) 4.Stochastic Momentum Index of Williams R% (Williams Percent Range) 5.Stochastic Momentum Index of FT (Fisher Transform) 6.Stochastic Momentum Index of CCI (Commodity Channel Index) 7.Stochastic Momentum Index of UO (Ultimate Oscillator) 8.Stochastic Momentum Index of MACD (Moving Average Convergence/Divergence) 9.Stochastic Momentum Index of Volume 10.Stochastic Momentum Index of MFI (Money Flow Index) 11.Stochastic Momentum Index of CMF (Chaikin Money Flow) 12.Stochastic Momentum Index of On Balance Volume (OBV) 13.Stochastic Momentum Index of Price-Volume Trend (PVT) 14.Stochastic Momentum Index of Volume Oscillator (VO) 15.Stochastic Momentum Index of Positive Volume Index (PVI) 16.Stochastic Momentum Index of Negative Volume Index (NVI) ## Relative Strength Index: 1. RSI for Volume 2. RSI for Moving Average
rsi(source, length) ββRSI (Relative Strengh Index). Measures the relative strength of recent price gains to recent price losses of an asset. ββParameters: ββββsource: (float) Source of series (close, high, low, etc.) ββββlength: (int) Period of loopback ββReturns: (float) Series of RSI
roc(source, length) ββROC (Rate of Change). Measures the percentage change in price of an asset over a specified time period. ββParameters: ββββsource: (float) Source of series (close, high, low, etc.) ββββlength: (int) Period of loopback ββReturns: (float) Series of ROC
stoch(kLength, kSmoothing, dSmoothing, maTypeK, maTypeD, almaOffsetKD, almaSigmaKD, lsmaOffSetKD) ββStochastic Oscillator. Compares the current price of an asset to its price range over a specified time period. ββParameters: ββββkLength ββββkSmoothing: (int) Period for smoothig stochastic ββββdSmoothing: (int) Period for signal (moving average of stochastic) ββββmaTypeK: (int) Type of Moving Average for Stochastic Oscillator ββββmaTypeD: (int) Type of Moving Average for Stochastic Oscillator Signal ββββalmaOffsetKD: (float) Offset for Arnaud Legoux Moving Average for Oscillator and Signal ββββalmaSigmaKD: (float) Sigma for Arnaud Legoux Moving Average for Oscillator and Signal ββββlsmaOffSetKD: (int) Offset for Least Squares Moving Average for Oscillator and Signal ββReturns: [float, float] A tuple of Stochastic Oscillator and Moving Average of Stochastic Oscillator
stoch(source, kLength, kSmoothing, dSmoothing, maTypeK, maTypeD, almaOffsetKD, almaSigmaKD, lsmaOffSetKD) ββStochastic Oscillator. Customized source. Compares the current price of an asset to its price range over a specified time period. ββParameters: ββββsource: (float) Source of series (close, high, low, etc.) ββββkLength: (int) Period of loopback to calculate the stochastic ββββkSmoothing: (int) Period for smoothig stochastic ββββdSmoothing: (int) Period for signal (moving average of stochastic) ββββmaTypeK: (int) Type of Moving Average for Stochastic Oscillator ββββmaTypeD: (int) Type of Moving Average for Stochastic Oscillator Signal ββββalmaOffsetKD: (float) Offset for Arnaud Legoux Moving Average for Stoch and Signal ββββalmaSigmaKD: (float) Sigma for Arnaud Legoux Moving Average for Stoch and Signal ββββlsmaOffSetKD: (int) Offset for Least Squares Moving Average for Stoch and Signal ββReturns: [float, float] A tuple of Stochastic Oscillator and Moving Average of Stochastic Oscillator
tsi(source, shortLength, longLength, maType, almaOffset, almaSigma, lsmaOffSet) ββTSI (True Strengh Index). Measures the price change, calculating the ratio of the price change (positive or negative) in relation to the absolute price change. The values of both are smoothed twice to reduce noise, and the final result is normalized in a range between 100 and -100. ββParameters: ββββsource: (float) Source of series (close, high, low, etc.) ββββshortLength: (int) Short length ββββlongLength: (int) Long length ββββmaType: (int) Type of Moving Average for TSI ββββalmaOffset: (float) Offset for Arnaud Legoux Moving Average ββββalmaSigma: (float) Sigma for Arnaud Legoux Moving Average ββββlsmaOffSet: (int) Offset for Least Squares Moving Average ββReturns: (float) TSI
smi(sourceTSI, shortLengthTSI, longLengthTSI, maTypeTSI, almaOffsetTSI, almaSigmaTSI, lsmaOffSetTSI, maTypeSignal, smoothingLengthSignal, almaOffsetSignal, almaSigmaSignal, lsmaOffSetSignal) ββSMI (Stochastic Momentum Index). A TSI (True Strengh Index) plus a signal line. ββParameters: ββββsourceTSI: (float) Source of series for TSI (close, high, low, etc.) ββββshortLengthTSI: (int) Short length for TSI ββββlongLengthTSI: (int) Long length for TSI ββββmaTypeTSI: (int) Type of Moving Average for Signal of TSI ββββalmaOffsetTSI: (float) Offset for Arnaud Legoux Moving Average ββββalmaSigmaTSI: (float) Sigma for Arnaud Legoux Moving Average ββββlsmaOffSetTSI: (int) Offset for Least Squares Moving Average ββββmaTypeSignal ββββsmoothingLengthSignal ββββalmaOffsetSignal ββββalmaSigmaSignal ββββlsmaOffSetSignal ββReturns: [float, float, float] A tuple with TSI, signal of TSI and histogram of difference
wpr(source, length) ββWilliams R% (Williams Percent Range). Compares the current price of an asset to its highest high and lowest low over a specified time period. ββParameters: ββββsource: (float) Source of series (close, high, low, etc.) ββββlength: (int) Period of loopback ββReturns: (float) Series of Williams R%
cci(source, length, maType, almaOffset, almaSigma, lsmaOffSet) ββCCI (Commodity Channel Index). Measures the relationship between an asset's current price and its moving average. ββParameters: ββββsource: (float) Source of series (close, high, low, etc.) ββββlength: (int) Period of loopback ββββmaType: (int) Type of Moving Average ββββalmaOffset: (float) Offset for Arnaud Legoux Moving Average ββββalmaSigma: (float) Sigma for Arnaud Legoux Moving Average ββββlsmaOffSet: (int) Offset for Least Squares Moving Average ββReturns: (float) Series of CCI
ultimateOscillator(fastLength, middleLength, slowLength) ββUO (Ultimate Oscilator). Combines three different time periods to help identify possible reversal points. ββParameters: ββββfastLength: (int) Fast period of loopback ββββmiddleLength: (int) Middle period of loopback ββββslowLength: (int) Slow period of loopback ββReturns: (float) Series of Ultimate Oscilator
ultimateOscillator(source, fastLength, middleLength, slowLength) ββUO (Ultimate Oscilator). Customized source. Combines three different time periods to help identify possible reversal points. ββParameters: ββββsource: (float) Source of series (close, high, low, etc.) ββββfastLength: (int) Fast period of loopback ββββmiddleLength: (int) Middle period of loopback ββββslowLength: (int) Slow period of loopback ββReturns: (float) Series of Ultimate Oscilator
macd(source, fastLength, slowLength, signalLength, maTypeFast, maTypeSlow, maTypeMACD, almaOffset, almaSigma, lsmaOffSet) ββMACD (Moving Average Convergence/Divergence). Shows the difference between short-term and long-term exponential moving averages. ββParameters: ββββsource: (float) Source of series (close, high, low, etc.) ββββfastLength: (int) Period for fast moving average ββββslowLength: (int) Period for slow moving average ββββsignalLength: (int) Signal length ββββmaTypeFast: (int) Type of fast moving average ββββmaTypeSlow: (int) Type of slow moving average ββββmaTypeMACD: (int) Type of MACD moving average ββββalmaOffset: (float) Offset for Arnaud Legoux Moving Average ββββalmaSigma: (float) Sigma for Arnaud Legoux Moving Average ββββlsmaOffSet: (int) Offset for Least Squares Moving Average ββReturns: [float, float, float] A tuple with MACD, Signal, and Histgram
fisher(length) ββFisher Transform. Normalize prices into a Gaussian normal distribution. ββParameters: ββββlength ββReturns: [float, float] A tuple with Fisher Transform and signal
fisher(source, length) ββFisher Transform. Customized source. Normalize prices into a Gaussian normal distribution. ββParameters: ββββsource: (float) Source of series (close, high, low, etc.) ββββlength ββReturns: [float, float] A tuple with Fisher Transform and signal
inverseFisher(source, length, subtrahend, denominator) ββInverse Fisher Transform. Transform the values of the Fisher Transform into a smaller and more easily interpretable scale is through the application of an inverse transformation to the hyperbolic tangent function. This transformation takes the values of the FT, which range from -infinity to +infinity, to a scale limited between -1 and +1, allowing them to be more easily visualized and compared. ββParameters: ββββsource: (float) Source of series (close, high, low, etc.) ββββlength: (int) Period for loopback ββββsubtrahend: (int) Denominator. Useful in unbounded indicators. For example, in CCI. ββββdenominator ββReturns: (float) Series of Inverse Fisher Transform
premierStoch(length, smoothlen) ββPremier Stochastic Oscillator (PSO). Normalizes the standard stochastic oscillator by applying a five-period double exponential smoothing average of the %K value, resulting in a symmetric scale of 1 to -1. ββParameters: ββββlength: (int) Period for loopback ββββsmoothlen: (int) Period for smoothing ββReturns: (float) Series of PSO
premierStoch(source, smoothlen, subtrahend, denominator) ββPremier Stochastic Oscillator (PSO) of custom source. Normalizes the source by applying a five-period double exponential smoothing average. ββParameters: ββββsource: (float) Source of series (close, high, low, etc.) ββββsmoothlen: (int) Period for smoothing ββββsubtrahend: (int) Denominator. Useful in unbounded indicators. For example, in CCI. ββββdenominator ββReturns: (float) Series of PSO
Hi, Thank you so much for your work. Been a fan of you after seeing your Script SMI MFI. I am new to this development part, I am trying to add above code in to a script in trading view but it is coming as black. Please assist.
andre_007
β
@nkumarkr01, this code available here does not print anything on the screen. It only aggregates the calculation of certain indicators. The image I posted here are examples that use the library.
@andre_007, Hi, in SMIMFI function what should we do to pass 'series int'? Now it is throwing error if I pass 'series int' as it expects 'simple int'. Thanks as always.