SSL Indicator free

by BartNL in category Trend at 10/05/2021
Description

The SSL indicator consists of two SMAs, one of the Highs,the other of the Lows.

On Close above High SMA, the indicator is Long, on Close below Low SMA, the indicator is Short.
The Long vs. Short is visualized by a red and a blue line.
When Long, the blue line is at the High SMA and the red line is at the Low SMA.
When Short, the red line is at the High SMA and the blue line is at the Low SMA.

Furthermore, transitions between Long and Short coincide with crossing of the red and blue lines.

 

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 SSLIndicator : Indicator
    {
        [Parameter(DefaultValue = 10, MinValue = 1)]
        public int Period { get; set; }

        [Output("SSL High", LineColor = "#3BB3E4")]
        public IndicatorDataSeries High { get; set; }

        [Output("SSL Low", LineColor = "#FF006E")]
        public IndicatorDataSeries Low { get; set; }

        private SimpleMovingAverage SMAHigh;
        private SimpleMovingAverage SMALow;

        public SSLIndicator()
        {
        }

        protected override void Initialize()
        {
            SMAHigh = Indicators.SimpleMovingAverage(Bars.HighPrices, Period);
            SMALow = Indicators.SimpleMovingAverage(Bars.LowPrices, Period);
        }

        public int GetDirectionAt(int index)
        {
            var p = High[index];
            var m = Low[index];
            return double.IsNaN(p) || double.IsNaN(m) ? 0 : p >= m ? +1 : -1;
        }

        public override void Calculate(int index)
        {
            var h = SMAHigh.Result[index];
            var l = SMALow.Result[index];
            var c = Bars.ClosePrices[index];
            var prevDir = index > 0 ? GetDirectionAt(index - 1) : 0;
            var r = c > h ? +1 : c < l ? -1 : prevDir;
            High[index] = r > 0 ? h : r < 0 ? l : double.NaN;
            Low[index] = r > 0 ? l : r < 0 ? h : double.NaN;
        }
    }
}
Comments

Symposium - May 11, 2021 @ 03:09

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 SSLIndicator : Indicator
    {
        [Parameter(DefaultValue = 10, MinValue = 1)]
        public int Period { get; set; }

        [Parameter("Fast MA Type")]
        public MovingAverageType MAType { get; set; }

        [Output("SSL High", LineColor = "#3BB3E4")]
        public IndicatorDataSeries High { get; set; }

        [Output("SSL Low", LineColor = "#FF006E")]
        public IndicatorDataSeries Low { get; set; }

        private MovingAverage MAHigh;
        private MovingAverage MALow;

        public SSLIndicator()
        {
        }

        protected override void Initialize()
        {
            MAHigh = Indicators.MovingAverage(Bars.HighPrices, Period, MAType);
            MALow = Indicators.MovingAverage(Bars.LowPrices, Period, MAType);
        }

        public int GetDirectionAt(int index)
        {
            var p = High[index];
            var m = Low[index];
            return double.IsNaN(p) || double.IsNaN(m) ? 0 : p >= m ? +1 : -1;
        }

        public override void Calculate(int index)
        {
            var h = MAHigh.Result[index];
            var l = MALow.Result[index];
            var c = Bars.ClosePrices[index];
            var prevDir = index > 0 ? GetDirectionAt(index - 1) : 0;
            var r = c > h ? +1 : c < l ? -1 : prevDir;
            High[index] = r > 0 ? h : r < 0 ? l : double.NaN;
            Low[index] = r > 0 ? l : r < 0 ? h : double.NaN;
        }
    }
}

Symposium - May 11, 2021 @ 03:12

Just an update to Bart's SSL Indicator which allows you to access variable types of Moving Averages.

Cheers

BartNL - May 11, 2021 @ 13:34

Thanks for the update, but I just saw an SSL indicator has already been published. So I think I just remove mine.

khushal09 - May 12, 2021 @ 16:58

i have a trend line formula similar to your ssl indicator ..but in another language .. can you convert or code that formula.. please

0