Category Trend  Published on 10/07/2023

Tirone Levels indicator

Description

John Tirone Levels are a set of the appropriate support and resistance levels based on a trading range for a certain period of time.

Usually they are used only to improve visual perception of the market price moves. In this case, the Midpoint method is used for the calculation of all three Tirone Levels.

Market minimum and maximum for a certain period of time are calculated at first.



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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class mTironeLevels : Indicator
    {
        [Parameter("Periods (15)", DefaultValue = 15)]
        public int inpPeriods { get; set; }

        [Output("Upper TironeLevels", IsHistogram = false, LineColor = "Magenta", LineStyle = LineStyle.LinesDots, PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries outTironeLevelsUpper { get; set; }
        [Output("Middle TironeLevels", IsHistogram = false, LineColor = "Magenta", LineStyle = LineStyle.LinesDots, PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries outTironeLevelsMiddle { get; set; }
        [Output("Lower TironeLevels", IsHistogram = false, LineColor = "Magenta", LineStyle = LineStyle.LinesDots, PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries outTironeLevelsLower { get; set; }

        private IndicatorDataSeries _hh, _ll, _up, _mid, _dn;


        protected override void Initialize()
        {
            _hh = CreateDataSeries();
            _ll = CreateDataSeries();
            _up = CreateDataSeries();
            _mid = CreateDataSeries();
            _dn = CreateDataSeries();
        }

        public override void Calculate(int i)
        {
            _hh[i] = i > inpPeriods ? Bars.HighPrices.Maximum(inpPeriods) : Bars.HighPrices[i];
            _ll[i] = i > inpPeriods ? Bars.LowPrices.Minimum(inpPeriods) : Bars.LowPrices[i];
            _up[i] = _hh[i] - (_hh[i] - _ll[i]) / 3;
            _mid[i] = _ll[i] + (_hh[i] - _ll[i]) / 2;
            _dn[i] = _ll[i] + (_hh[i] - _ll[i]) / 3;

            outTironeLevelsUpper[i] = _up[i];
            outTironeLevelsMiddle[i] = _mid[i];
            outTironeLevelsLower[i] = _dn[i];
        }
    }
}


mfejza's avatar
mfejza

Joined on 25.01.2022

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: mTironeLevels.algo
  • Rating: 5
  • Installs: 979
Comments
Log in to add a comment.
No comments found.