Category Trend  Published on 19/04/2020

Custom Wavetrend

Description

Haven't found any Wavetrend here so i built one on my own.

Instead of the original calculation i use  an average of RSI, MFI and RMI indexed to 0. Pretty similar result.

Reduces the noise and can get you in earlier than RSI Cloud.

With Signal line, Histogram and OS/OB areas.

Can also be used for spotting Divergences.

 

 

Possible Entries:

- Wave inside OS/OB Area and Lines crossing 

- Wave Crossing 0-Line with strong Histogram momentum

- Wave Divergences

For Exits: I'd suggest to determine Support/Resistance Levels, or wait for an Signal to opposite direction.

 

Do not blindly follow these Entries, Watch Price action to determine if you want to take the Trade or not.

(Click for full size image)

 

If you like my work, feel free to spend me a Corona Beer :-)

Donate


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

namespace cAlgo.Indicators
{
    [Cloud("OB1 Level", "OB2 Level")]
    [Cloud("OS1 Level", "OS2 Level")]
    [Cloud("WAVE", "Zero Level")]
    [Cloud("WAVE", "SIGNAL")]
    [Cloud("WAVE", "SIGNAL")]

    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class CUSTOMWAVETREND : Indicator
    {
        /////////////////////////////////////////////////////// PARAMETERS 
        [Parameter("RSI/MFI/RMI Length", Group = "General", DefaultValue = 10)]
        public int rsiPeriod { get; set; }
        [Parameter("Momentum Length", Group = "General", DefaultValue = 5, MinValue = 0)]
        public int RMImomentum { get; set; }
        [Parameter("Histogram auto-color", Group = "General", DefaultValue = false)]
        public bool OnAdaptive { get; set; }

        // Smoothing
        [Parameter("MA type", Group = "Smoothing", DefaultValue = MovingAverageType.Exponential)]
        public MovingAverageType ALL_MAtype { get; set; }
        [Parameter("Length", Group = "Smoothing", DefaultValue = 4, MinValue = 0)]
        public int ALL_smooth { get; set; }

        // Signal
        [Parameter("ST Signal | MA type", Group = "Signal Lines", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType ST_Signal_MAtype { get; set; }
        [Parameter("ST Signal | Length", Group = "Signal Lines", DefaultValue = 5)]
        public int ST_Signal_length { get; set; }

        // OS/OB levels
        [Parameter("OS1 Level", Group = "Levels", DefaultValue = -30)]
        public int OS1_value { get; set; }
        [Parameter("OS2 Level", Group = "Levels", DefaultValue = -40)]
        public int OS2_value { get; set; }
        [Parameter("OB1 Level", Group = "Levels", DefaultValue = 30)]
        public int OB1_value { get; set; }
        [Parameter("OB2 Level", Group = "Levels", DefaultValue = 40)]
        public int OB2_value { get; set; }

        /////////////////////////////////////////////////////// LEVELS 
        [Output("OB1 Level", LineColor = "DarkRed", LineStyle = LineStyle.Dots, Thickness = 1)]
        public IndicatorDataSeries OB1_level { get; set; }
        [Output("OB2 Level", LineColor = "DarkRed", LineStyle = LineStyle.Dots, Thickness = 1)]
        public IndicatorDataSeries OB2_level { get; set; }
        // ---------------
        [Output("OS1 Level", LineColor = "DarkGreen", LineStyle = LineStyle.Dots, Thickness = 1)]
        public IndicatorDataSeries OS1_level { get; set; }
        [Output("OS2 Level", LineColor = "DarkGreen", LineStyle = LineStyle.Dots, Thickness = 1)]
        public IndicatorDataSeries OS2_level { get; set; }
        // ---------------
        [Output("Zero Level", LineColor = "Red", LineStyle = LineStyle.Solid, Thickness = 1)]
        public IndicatorDataSeries midlevel { get; set; }

        /////////////////////////////////////////////////////// LINES 
        [Output("WAVE", LineColor = "Lime", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries ALL { get; set; }

        [Output("SIGNAL", LineColor = "DarkRed", PlotType = PlotType.Line, Thickness = 1)]
        public IndicatorDataSeries SIGNAL { get; set; }

        /////////////////////////////////////////////////////// HISTOGRAM 
        [Output("Histogram Up", PlotType = PlotType.Histogram, LineColor = "88FFC000", Thickness = 4)]
        public IndicatorDataSeries HistogramPositive { get; set; }
        [Output("Histogram Down", PlotType = PlotType.Histogram, LineColor = "44FFC000", Thickness = 4)]
        public IndicatorDataSeries HistogramNegative { get; set; }


        //////////////////////   
        private RelativeStrengthIndex _rsi;
        private MoneyFlowIndex _mfi;
        private IndicatorDataSeries _together;
        private IndicatorDataSeries _rmi_momdown;
        private IndicatorDataSeries _rmi_momup;
        private IndicatorDataSeries _rmi;
        private IndicatorDataSeries _histogram;
        private ExponentialMovingAverage _rmi_up;
        private ExponentialMovingAverage _rmi_down;
        private MovingAverage _all;
        private MovingAverage _signal;

        /////////////////////////////////////////////////////// INITIALIZE 
        protected override void Initialize()
        {
            DataSeries _ds = Bars.TypicalPrices;
            _together = CreateDataSeries();
            _histogram = CreateDataSeries();

            _rmi_momup = CreateDataSeries();
            _rmi_momdown = CreateDataSeries();
            _rmi = CreateDataSeries();

            _rmi_up = Indicators.ExponentialMovingAverage(_rmi_momup, rsiPeriod);
            _rmi_down = Indicators.ExponentialMovingAverage(_rmi_momdown, rsiPeriod);

            _rsi = Indicators.RelativeStrengthIndex(_ds, rsiPeriod);
            _mfi = Indicators.MoneyFlowIndex(rsiPeriod);

            _all = Indicators.MovingAverage(_together, ALL_smooth, ALL_MAtype);
            _signal = Indicators.MovingAverage(_all.Result, ST_Signal_length, ST_Signal_MAtype);
        }


        /////////////////////////////////////////////////////// CALCULATE 
        public override void Calculate(int index)
        {
            // Levels
            OS1_level[index] = OS1_value;
            OS2_level[index] = OS2_value;
            OB1_level[index] = OB1_value;
            OB2_level[index] = OB2_value;
            midlevel[index] = 0;

            // RMI calculation
            _rmi_momup[index] = Math.Max(Bars.ClosePrices[index] - Bars.ClosePrices[index - RMImomentum], 0);
            _rmi_momdown[index] = Math.Max(Bars.ClosePrices[index - RMImomentum] - Bars.ClosePrices[index], 0);
            _rmi[index] = 100 - (100 / (1 + _rmi_up.Result[index] / _rmi_down.Result[index]));

            _together[index] = (_rsi.Result[index] + _mfi.Result[index] + _rmi[index]) / 3;

            // Histogram
            _histogram[index] = _all.Result[index] - _signal.Result[index];

            if (OnAdaptive)
            {
                if (_histogram[index] > _histogram[index - 1])
                    HistogramPositive[index] = _histogram[index];

                else if (_histogram[index] < _histogram[index - 1])
                    HistogramNegative[index] = _histogram[index];
            }
            else
            {
                if (_histogram[index] > 0)
                    HistogramPositive[index] = _histogram[index];

                else if (_histogram[index] < 0)
                    HistogramNegative[index] = _histogram[index];
            }

            // Plots
            ALL[index] = _all.Result[index] - 50;
            SIGNAL[index] = _signal.Result[index] - 50;

        }
    }
}


DO
DontMatter

Joined on 15.11.2019

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: CUSTOM WAVETREND.algo
  • Rating: 5
  • Installs: 3072
Comments
Log in to add a comment.
JA
jacopotrono · 1 year ago

Hi DontMatter, could you write me in DM?

I would like to know if it's possible to add possibility to chose Timeframe for the Custom WT.

Thanks in advance!

DO
DontMatter · 4 years ago

Hi, i updated the Description with possible entries

IA
IandelMar · 4 years ago

Hi, great work, can you tell the Buy/ Sell ENtrys and Exits? Then I spent a Beer ;-)