hhhhpp free

by ctid4935132 in category Trend at 23/09/2022
Description

usingcAlgo.API;

usingcAlgo.API.Indicators;

 

namespacecAlgo.Indicators

{

    [Levels(0)]

    [Indicator(AccessRights = AccessRights.None)]

    publicclassElliotOscillator : Indicator

    {

        privateSimpleMovingAverage _fastSma;

        privateSimpleMovingAverage _slowSma;

        privateSimpleMovingAverage _sma100;

        privateSimpleMovingAverage _sma200;

        privateSimpleMovingAverage _sma20;

 

        privatedouble_d;

        privatebool_upTrend;

        privatebool_neutral;

        privateIndicatorDataSeries _elliot;

 

 

        [Parameter]

        publicDataSeries Source { get; set; }

 

        [Parameter("FastPeriod", DefaultValue = 5)]

        publicintFastPeriod { get; set; }

         

        [Parameter("SlowPeriod", DefaultValue = 34)]

        publicintSlowPeriod { get; set; }

 

        [Output("UpTrend", Color = Colors.Green, PlotType = PlotType.Histogram, Thickness = 2)]

        publicIndicatorDataSeries UpTrend { get; set; }

        [Output("DownTrend", Color = Colors.Red, PlotType = PlotType.Histogram, Thickness = 2)]

        publicIndicatorDataSeries DownTrend { get; set; }

        [Output("Neutral", Color = Colors.Gray, PlotType = PlotType.Histogram, Thickness = 2)]

        publicIndicatorDataSeries Neutral { get; set; }

         

        [Output("Line", Color = Colors.Red)]

        publicIndicatorDataSeries Line { get; set; }

 

        protectedoverridevoidInitialize()

        {

            _fastSma = Indicators.SimpleMovingAverage(Source, FastPeriod);

            _slowSma = Indicators.SimpleMovingAverage(Source, SlowPeriod);

            _sma100 = Indicators.SimpleMovingAverage(Source, 100);

            _sma200 = Indicators.SimpleMovingAverage(Source, 200);

            _sma20 = Indicators.SimpleMovingAverage(Source, 20);

            _elliot = CreateDataSeries();

 

        }

        publicoverridevoidCalculate(intindex)

        {

            if(index < 3)

                return;

 

            _elliot[index] = _fastSma.Result[index] - _slowSma.Result[index];

            Line[index] = _fastSma.Result[index - 3] - _slowSma.Result[index - 3];

 

            if(_sma100.Result.LastValue > _sma200.Result.LastValue

                && _sma20.Result.LastValue >_sma100.Result.LastValue)

            {

                UpTrend[index] = _elliot[index];

                DownTrend[index] = double.NaN;

                Neutral[index] = double.NaN;

            }

            elseif(_sma100.Result.LastValue < _sma200.Result.LastValue

                && _sma20.Result.LastValue < _sma100.Result.LastValue)

            {

                DownTrend[index] = _elliot[index];

                UpTrend[index] = double.NaN;

                Neutral[index] = double.NaN;

            }

            else

            {

                Neutral[index] = _elliot[index];

                UpTrend[index] = double.NaN;

                DownTrend[index] = double.NaN;

            }

        }

    }

}

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

namespace cAlgo.Indicators
{
    [Levels(0)]
    [Indicator(AccessRights = AccessRights.None)]
    public class ElliotOscillator : Indicator
    {
        private SimpleMovingAverage _fastSma;
        private SimpleMovingAverage _slowSma;
        private SimpleMovingAverage _sma100;
        private SimpleMovingAverage _sma200;
        private SimpleMovingAverage _sma20;

        private double _d;
        private bool _upTrend;
        private bool _neutral;
        private IndicatorDataSeries _elliot;


        [Parameter]
        public DataSeries Source { get; set; }

        [Parameter("FastPeriod", DefaultValue = 5)]
        public int FastPeriod { get; set; }
        
        [Parameter("SlowPeriod", DefaultValue = 34)]
        public int SlowPeriod { get; set; }

        [Output("UpTrend", Color = Colors.Green, PlotType = PlotType.Histogram, Thickness = 2)]
        public IndicatorDataSeries UpTrend { get; set; }
        [Output("DownTrend", Color = Colors.Red, PlotType = PlotType.Histogram, Thickness = 2)]
        public IndicatorDataSeries DownTrend { get; set; }
        [Output("Neutral", Color = Colors.Gray, PlotType = PlotType.Histogram, Thickness = 2)]
        public IndicatorDataSeries Neutral { get; set; }
        
        [Output("Line", Color = Colors.Red)]
        public IndicatorDataSeries Line { get; set; }

        protected override void Initialize()
        {
            _fastSma = Indicators.SimpleMovingAverage(Source, FastPeriod);
            _slowSma = Indicators.SimpleMovingAverage(Source, SlowPeriod);
            _sma100 = Indicators.SimpleMovingAverage(Source, 100);
            _sma200 = Indicators.SimpleMovingAverage(Source, 200);
            _sma20 = Indicators.SimpleMovingAverage(Source, 20);
            _elliot = CreateDataSeries();

        }
        public override void Calculate(int index)
        {
            if (index < 3)
                return;

            _elliot[index] = _fastSma.Result[index] - _slowSma.Result[index];
            Line[index] = _fastSma.Result[index - 3] - _slowSma.Result[index - 3];

            if (_sma100.Result.LastValue > _sma200.Result.LastValue
                && _sma20.Result.LastValue >_sma100.Result.LastValue)
            {
                UpTrend[index] = _elliot[index];
                DownTrend[index] = double.NaN;
                Neutral[index] = double.NaN;
            }
            else if (_sma100.Result.LastValue < _sma200.Result.LastValue
                && _sma20.Result.LastValue < _sma100.Result.LastValue)
            {
                DownTrend[index] = _elliot[index];
                UpTrend[index] = double.NaN;
                Neutral[index] = double.NaN;
            }
            else
            {
                Neutral[index] = _elliot[index];
                UpTrend[index] = double.NaN;
                DownTrend[index] = double.NaN;
            }
        }
    }
}
Comments
0