SZO (Sentiment Zone Oscillator) free

by mfejza in category Oscilator at 18/01/2023
Description

The SZO (Sentiment Zone Oscillator) indicator shows the market sentiment (activity and direction) and zones of excessive activity (overbought/oversold zones). It can display a dynamic channel, beyond which deals are seen as undesirable because of the high probability of a change in sentiment and of reversal.

If the indicator line moves beyond the channel and at the same time enters the overbought/oversold zone, this may mean that the market trend can change soon. The indicator often warns of such a possible change in advance, so it is advisable to use it in combination with another confirmation indicator.

Notification Publishing copyrighted material is strictly prohibited. If you believe there is copyrighted material in this section you may use the Copyright Infringement Notification form to submit a claim.
Formula / Source Code
Language: C#
Trading Platform: cAlgocTrader
using System;
using cAlgo.API;
using cAlgo.API.Collections;
using cAlgo.API.Indicators;
using cAlgo.API.Internals;

namespace cAlgo
{
    [Levels(0, -7, +7)]
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class mSZO : Indicator
    {
        [Parameter("Period SZO", DefaultValue = 14)]
        public int inpPeriodSZO { get; set; }
        [Parameter("Show Levels", DefaultValue = true)]
        public bool inpShowDLev { get; set; }
        [Parameter("Show Mid Levels", DefaultValue = true)]
        public bool inpShowMidLev { get; set; }
        [Parameter("inpPeriodDLev", DefaultValue = 30)]
        public int inpPeriodDLev { get; set; }
        [Parameter("InpPercentDLev", DefaultValue = 95.0)]
        public double InpPercentDLev { get; set; }

        [Output("Main", IsHistogram = false, LineColor = "Black", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outSZO { get; set; }
        [Output("outTop", IsHistogram = false, LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outTop { get; set; }
        [Output("outBottom", IsHistogram = false, LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outBottom { get; set; }
        [Output("outMiddle", IsHistogram = false, LineColor = "LightGreen", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outMiddle { get; set; }

        private IndicatorDataSeries _data, _szo;
        private ExponentialMovingAverage _ema1, _ema2, _ema3;
        private double _highlvl, lowlvl, _range, _rangeproc;


        protected override void Initialize()
        {
            _data = CreateDataSeries();
            _szo = CreateDataSeries();
            _ema1 = Indicators.ExponentialMovingAverage(_data, inpPeriodSZO);
            _ema2 = Indicators.ExponentialMovingAverage(_ema1.Result, inpPeriodSZO);
            _ema3 = Indicators.ExponentialMovingAverage(_ema2.Result, inpPeriodSZO);
        }

        public override void Calculate(int i)
        {
            _data[i] = (i > 1 && Bars.ClosePrices[i] > Bars.ClosePrices[i - 1] ? 1 : -1);
            _szo[i] = 100.0 * ((3 * _ema1.Result[i] - 3 * _ema2.Result[i] + _ema3.Result[i]) / inpPeriodSZO);

            outSZO[i] = _szo[i];

            if (inpShowDLev && i > inpPeriodDLev)
            {
                _highlvl = _szo[i];
                lowlvl = _szo[i];
                for (int j = inpPeriodDLev - 1; j >= 0; j--)
                {
                    if (_highlvl < _szo[i - j])
                        _highlvl = _szo[i - j];
                    if (lowlvl > _szo[i - j])
                        lowlvl = _szo[i - j];
                }
                _range = _highlvl - lowlvl;
                _rangeproc = _range * (InpPercentDLev / 100.0);

                outTop[i] = lowlvl + _rangeproc;
                outBottom[i] = _highlvl - _rangeproc;
                outMiddle[i] = inpShowMidLev == true ? (lowlvl + _rangeproc + _highlvl - _rangeproc) / 2 : double.NaN;
            }
        }
    }
}
Comments

milan45 - January 23, 2023 @ 08:31

The Sentiment Zone strategy is based on values of Sentiment Zone Oscillator (SZO) and their relation with dynamic overbought and oversold levels.

0