TrendValue indicator free

by mfejza in category Trend at 01/09/2022
Description

The TrendValue indicator show trending zones for long and short trades

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.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class mTrendValue : Indicator
    {
        [Parameter("Range Period (10)", DefaultValue = 10, MinValue = 1, Group = "TrendValue")]
        public int inpRangePeriod { get; set; }
        [Parameter("ATR Period (10)", DefaultValue = 10, MinValue = 1, Group = "TrendValue")]
        public int inpATRPeriods { get; set; }
        [Parameter("ATR Sensitivity (1.618)", DefaultValue = 1.618, MinValue = 0.382, Group = "TrendValue")]
        public double inpATRSensitivity { get; set; }
        [Parameter("Smooth Type (sma)", DefaultValue = MovingAverageType.Simple, Group = "TrendValue")]
        public MovingAverageType inpSmoothType { get; set; }

        [Output("Trend Value", Thickness = 2, LineColor = "FF02AFF1")]
        public IndicatorDataSeries outTrendValue { get; set; }

        private MovingAverage _smah, _smal;
        private AverageTrueRange _atr;
        private IndicatorDataSeries _highSensivity, _lowSensivity, _trend, _tv;


        protected override void Initialize()
        {
            _smah = Indicators.MovingAverage(Bars.HighPrices, inpRangePeriod, inpSmoothType);
            _smal = Indicators.MovingAverage(Bars.LowPrices, inpRangePeriod, inpSmoothType);
            _atr = Indicators.AverageTrueRange(inpATRPeriods, inpSmoothType);
            _highSensivity = CreateDataSeries();
            _lowSensivity = CreateDataSeries();
            _trend = CreateDataSeries();
            _tv = CreateDataSeries();
        }

        public override void Calculate(int i)
        {
            _highSensivity[i] = _smah.Result[i] * (1 + 0 / 100) + _atr.Result[i] * inpATRSensitivity;
            _lowSensivity[i] = _smal.Result[i] * (1 - 0 / 100) - _atr.Result[i] * inpATRSensitivity;

            if (i < inpRangePeriod)
            {
                _trend[i] = +1;
                _tv[i] = Bars.ClosePrices[i];
                return;
            }

            _trend[i] = _trend[i - 1];

            if (Bars.ClosePrices[i] > _highSensivity[i - 1])
                _trend[i] = +1;
            if (Bars.ClosePrices[i] < _lowSensivity[i - 1])
                _trend[i] = -1;

            if (_trend[i] > 0)
            {
                if (_lowSensivity[i] < _lowSensivity[i - 1])
                    _lowSensivity[i] = _lowSensivity[i - 1];
                _tv[i] = _lowSensivity[i];
            }
            if (_trend[i] < 0)
            {
                if (_highSensivity[i] > _highSensivity[i - 1])
                    _highSensivity[i] = _highSensivity[i - 1];
                _tv[i] = _highSensivity[i];
            }

            outTrendValue[i] = _tv[i];
        }
    }
}
Comments

lohip36065 - October 09, 2022 @ 14:17

Its a very nice post for the TrendValue indicator free and there are many ideas we can use to find the best results. By using the bestwritingsclues I saw many users are getting help to find the results they want. Good to have the right results we want.

0