Category Oscilators  Published on 01/07/2019

Stochastic Slow Strategy

Description

This is the original "Stochastic Slow Strategy" From Tradingview, all the default parameters are the default parameters from Tradingview, for your reference, below is the official code from Tradingview, I wrote the cTrader indicator based on the original code with no modification. Enjoy!

//@version=4
strategy("Stochastic Slow Strategy", overlay=true)
length = input(14, minval=1)
OverBought = input(80)
OverSold = input(20)
smoothK = 3
smoothD = 3

k = sma(stoch(close, high, low, length), smoothK)
d = sma(k, smoothD)

if (not na(k) and not na(d))
    if (crossover(k,d) and k < OverSold)
        strategy.entry("StochLE", strategy.long, comment="StochLE")
    if (crossunder(k,d) and k > OverBought)
        strategy.entry("StochSE", strategy.short, comment="StochSE")

//plot(strategy.equity, title="equity", color=color.red, linewidth=2, style=plot.style_areabr)

I am a software developer, I work for myself, there's no middleman involved. If you have a strategy and would like me to write the code for you. I can offer you the best price in the market. I only write cBot and cTrader indicators. I do not write MT4 and MT5 code.

For business contact, email me at info@mrkeyfob.com


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

namespace cAlgo
{
    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
    public class StochasticSlowStrategy : Indicator
    {
        [Parameter("%K Periods", DefaultValue = 14, MinValue = 1)]
        public int KPeriods { get; set; }

        [Parameter("%K Slowing", DefaultValue = 3, MinValue = 1)]
        public int KSlowing { get; set; }

        [Parameter("%D Periods", DefaultValue = 3, MinValue = 1)]
        public int DPeriods { get; set; }

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

        [Parameter("Over Bought", DefaultValue = 80, MinValue = 50, MaxValue = 100)]
        public int OverBought { get; set; }

        [Parameter("Over Sold", DefaultValue = 20, MinValue = 00, MaxValue = 50)]
        public int OverSold { get; set; }

        [Parameter("Indicator points away from high/low", DefaultValue = 10)]
        public int PointsAwayFrom { get; set; }

        [Output("Buy Signal", LineColor = "Green", PlotType = PlotType.Points, Thickness = 3)]
        public IndicatorDataSeries BuySignal { get; set; }

        [Output("Sell Signal", LineColor = "Red", PlotType = PlotType.Points, Thickness = 3)]
        public IndicatorDataSeries SellSignal { get; set; }

        private StochasticOscillator stochOscillator;

        protected override void Initialize()
        {
            stochOscillator = Indicators.StochasticOscillator(KPeriods, KSlowing, DPeriods, MAType);
        }

        public override void Calculate(int index)
        {
            BuySignal[index] = double.NaN;
            SellSignal[index] = double.NaN;
            if (stochOscillator.PercentK[index-1] <= stochOscillator.PercentD[index-1]
                && stochOscillator.PercentK[index] > stochOscillator.PercentD[index]
                && stochOscillator.PercentK[index]< OverSold)
                BuySignal[index] = MarketSeries.Low.LastValue - PointsAwayFrom * Symbol.TickSize;
            if (stochOscillator.PercentK[index-1] >= stochOscillator.PercentD[index-1]
                && stochOscillator.PercentK[index] < stochOscillator.PercentD[index]
                && stochOscillator.PercentK[index] > OverBought)
                SellSignal[index] = MarketSeries.High.LastValue + PointsAwayFrom * Symbol.TickSize;
        }
    }
}


jumpycalm's avatar
jumpycalm

Joined on 28.03.2019

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: Stochastic Slow Strategy.algo
  • Rating: 0
  • Installs: 2321
Comments
Log in to add a comment.
MA
markultrablack · 1 year ago

Finding a good developer is not so easy these days. In general, there are many ready-made solutions for business, but sometimes custom development is required, and it causes problems, since I don't know who to contact.

TR
traderadri · 2 years ago

I didn't work, nothing happens when I click to insert the indicator.