Category Oscilators  Published on 07/12/2021

True Strength Index (TSI)

Description

Developed by William Blau and introduced in Stocks & Commodities Magazine, the True Strength Index (TSI) is a momentum oscillator based on a double smoothing of price changes. Even though several steps are needed for calculation, the indicator is actually pretty straightforward. By smoothing price changes, TSI captures the ebbs and flows of price action with a steadier line that filters out the noise. As with most momentum oscillators, chartists can derive signals from overbought/oversold readings, centerline crossovers, bullish/bearish divergences and signal line crossovers.

The True Strength Index (TSI) is an oscillator that fluctuates between positive and negative territory. As with many momentum oscillators, the centerline defines the overall bias. The bulls have the momentum edge when TSI is positive and the bears have the edge when it's negative. As with MACD, a signal line can be applied to identify upturns and downturns. Signal line crossovers are, however, quite frequent and require further filtering with other techniques. Chartists can also look for bullish and bearish divergences to anticipate trend reversals; however, keep in mind that divergences can be misleading in a strong trend.

TSI is somewhat unique because it tracks the underlying price quite well. In other words, the oscillator can capture a sustained move in one direction or the other. The peaks and troughs in the oscillator often match the peaks and troughs in price. In this regard, chartists can draw trend lines and mark support/resistance levels using TSI. Line breaks can then be used to generate signals.

 

Github: GitHub - Doustzadeh/cTrader-Indicator

 


using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo
{
    [Levels(-25, 0, 25)]
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class TrueStrengthIndex : Indicator
    {
        // Double Smoothed PC
        // PC = Current Price minus Prior Price
        // First Smoothing = 25-period EMA of PC
        // Second Smoothing = 13-period EMA of 25-period EMA of PC

        // Double Smoothed Absolute PC
        // Absolute Price Change |PC| = Absolute Value of Current Price minus Prior Price
        // First Smoothing = 25-period EMA of |PC|
        // Second Smoothing = 13-period EMA of 25-period EMA of |PC|

        // TSI = 100 x (Double Smoothed PC / Double Smoothed Absolute PC)

        [Parameter("Source")]
        public DataSeries Source { get; set; }

        [Parameter("First Smoothing", DefaultValue = 25, MinValue = 1)]
        public int FirstSmoothingPeriods { get; set; }

        [Parameter("Second Smoothing", DefaultValue = 13, MinValue = 1)]
        public int SecondSmoothingPeriods { get; set; }

        [Parameter("Signal Periods", DefaultValue = 7, MinValue = 1)]
        public int SignalPeriods { get; set; }

        [Output("TSI", LineColor = "DodgerBlue")]
        public IndicatorDataSeries TSI { get; set; }

        [Output("Signal", LineColor = "Red")]
        public IndicatorDataSeries Signal { get; set; }

        private IndicatorDataSeries PC, APC;
        private ExponentialMovingAverage FirstSmoothingPC, SecondSmoothingPC, FirstSmoothingAPC, SecondSmoothingAPC;
        private ExponentialMovingAverage SignalEMA;

        protected override void Initialize()
        {
            PC = CreateDataSeries();
            FirstSmoothingPC = Indicators.ExponentialMovingAverage(PC, FirstSmoothingPeriods);
            SecondSmoothingPC = Indicators.ExponentialMovingAverage(FirstSmoothingPC.Result, SecondSmoothingPeriods);

            APC = CreateDataSeries();
            FirstSmoothingAPC = Indicators.ExponentialMovingAverage(APC, FirstSmoothingPeriods);
            SecondSmoothingAPC = Indicators.ExponentialMovingAverage(FirstSmoothingAPC.Result, SecondSmoothingPeriods);

            SignalEMA = Indicators.ExponentialMovingAverage(TSI, SignalPeriods);
        }

        public override void Calculate(int index)
        {
            PC[index] = Source[index] - Source[index - 1];
            APC[index] = Math.Abs(PC[index]);
            TSI[index] = 100 * (SecondSmoothingPC.Result[index] / SecondSmoothingAPC.Result[index]);

            Signal[index] = SignalEMA.Result[index];
        }
    }
}


Doustzadeh's avatar
Doustzadeh

Joined on 20.03.2016

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: True Strength Index.algo
  • Rating: 0
  • Installs: 1670
Comments
Log in to add a comment.
No comments found.