Stochastic Entry Marker free

by summer in category Oscilator at 07/10/2020
Description
  • ストキャスティクスのクロスを検知してチャート上に矢印を表示します。
  • ストキャスティクスのパラメータは任意に設定できます。

 

  • Detects stochastic crosses and displays an arrow on the chart.
  • The stochastic parameters can be set as desired.

 

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 StochasticEntryMarker : Indicator
    {

        [Parameter("K Periods", DefaultValue = 5)]
        public int kPeriods { get; set; }

        [Parameter("K Slowing", DefaultValue = 3)]
        public int kSlowing { get; set; }

        [Parameter("D Periods", DefaultValue = 3)]
        public int dPeriods { get; set; }

        [Parameter("UP Level", DefaultValue = 70)]
        public int Up_Level { get; set; }

        [Parameter("Down Level", DefaultValue = 30)]
        public int Down_Level { get; set; }

        [Parameter("MA Type", DefaultValue = MovingAverageType.Simple)]
        public MovingAverageType maType { get; set; }

        private StochasticOscillator _stochastic;

        private double offset = 1;

        protected override void Initialize()
        {
            // Initialize and create nested indicators
            _stochastic = Indicators.StochasticOscillator(kPeriods, kSlowing, dPeriods, maType);

        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = ...
            var bars = MarketData.GetBars(Chart.TimeFrame);

            //dedcloss
            if (_stochastic.PercentK.Last(2) > _stochastic.PercentD.Last(2) && _stochastic.PercentK.Last(1) < _stochastic.PercentD.Last(1))
            {
                Print("_stochastic.PercentD.Last(1) {0}", _stochastic.PercentD.Last(1));
                Print("_stochastic.PercentD.Last(2) {0}", _stochastic.PercentD.Last(2));
                if (_stochastic.PercentK.Last(2) > Up_Level)
                {
                    Chart.DrawIcon("test" + bars.OpenTimes.Last(1).ToString(), ChartIconType.DownArrow, bars.OpenTimes.Last(1), bars.HighPrices.Last(1) + (offset * Symbol.PipSize), "Red");
                }

            }

            //goldencloss
            if (_stochastic.PercentK.Last(2) < _stochastic.PercentD.Last(2) && _stochastic.PercentK.Last(1) > _stochastic.PercentD.Last(1))
            {

                Print("_stochastic.PercentD.Last(1) {0}", _stochastic.PercentD.Last(1));
                Print("_stochastic.PercentD.Last(2) {0}", _stochastic.PercentD.Last(2));
                if (_stochastic.PercentK.Last(2) < Down_Level)
                {
                    Chart.DrawIcon("test" + bars.OpenTimes.Last(1).ToString(), ChartIconType.UpArrow, bars.OpenTimes.Last(1), bars.LowPrices.Last(1) - (offset * Symbol.PipSize), "Yellow");
                }

            }
        }
    }
}
Comments
5