Category Oscilators  Published on 02/06/2023

Random Walk Index Polarised indicator

Description

Random Walk Index technical indicator was originally developed by Michael Poulos.

The RWI compares a security's price movements to random movements in an effort to determine if it's in a statistically significant trend. It can be used to generate decisive signals based on the strength of the underlying price trend.

In this version customized by Iba with polarization indicator values, the resulting sentiment zones are filtered, and the levels -1 and +1 are considered as logical trigger values. Additionally, the colors shadow green (bullish) and red (bearish) represent bullish and bearish sentiment, respectively.


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

namespace cAlgo
{
    [Levels(1, 0, -1)]
    [Cloud("RWI Bears", "RWI HighLevel", FirstColor = "Green", SecondColor = "Transparent", Opacity = 0.1)]
    [Cloud("RWI LowLevel", "RWI Bulls", FirstColor = "Red", SecondColor = "Transparent", Opacity = 0.1)]
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class mRWIp : Indicator
    {
        [Parameter("Period (13)", DefaultValue = 13, MinValue = 2)]
        public int inpPeriod { get; set; }
        [Parameter("ATR SmoothType (ema)", DefaultValue = MovingAverageType.Exponential)]
        public MovingAverageType inpSmoothType { get; set; }

        [Output("RWI Bulls", LineColor = "Green", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outBulls { get; set; }
        [Output("RWI Bears", LineColor = "Red", PlotType = PlotType.Line, LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries outBears { get; set; }
        [Output("RWI HighLevel", LineColor = "Transparent")]
        public IndicatorDataSeries outHighLevel { get; set; }
        [Output("RWI LowLevel", LineColor = "Transparent")]
        public IndicatorDataSeries outLowLevel { get; set; }

        private AverageTrueRange _atr;
        private IndicatorDataSeries _bulls, _bears;


        protected override void Initialize()
        {
            _atr = Indicators.AverageTrueRange(inpPeriod, inpSmoothType);
            _bulls = CreateDataSeries();
            _bears = CreateDataSeries();
        }

        public override void Calculate(int i)
        {
            _bulls[i] = (Bars.HighPrices[i] - (i>inpPeriod+1 ? Bars.LowPrices[i - 1 - inpPeriod] : Bars.LowPrices[i])) / _atr.Result[i] * Math.Sqrt(inpPeriod);
            _bears[i] = ((i>inpPeriod+1 ? Bars.HighPrices[i - 1 - inpPeriod] : Bars.HighPrices[i]) - Bars.LowPrices[i]) / _atr.Result[i] * Math.Sqrt(inpPeriod);

            outBulls[i] = _bulls[i];
            outBears[i] = -_bears[i];
            outHighLevel[i] = +1.0;
            outLowLevel[i] = -1.0;
        }
    }
}

mfejza's avatar
mfejza

Joined on 25.01.2022

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