SupportResistance free

by cxc_g in category Other at 23/11/2022
Description

//+------------------------------------------------------------------+

//|                                                SupportResistance |

//|                                       Copyright © 2016, UCHE OBI |

//|                                               Developer:UCHE OBI |

//|                                                 Skype:  OBI.UCHE |

//|                                      email:ucheceleste@Gmail.com |

//+------------------------------------------------------------------+

usingSystem;

usingcAlgo.API;

usingcAlgo.API.Internals;

usingcAlgo.API.Indicators;

usingcAlgo.Indicators;

 

namespacecAlgo

{

    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]

    publicclassSupportResistance : Indicator

    {

        [Parameter(DefaultValue = 10)]

        publicintrange { get; set; }

 

        [Parameter(DefaultValue = 3)]

        publicintconfirmations { get; set; }

 

        [Output("Res", Color = Colors.Black, LineStyle = LineStyle.DotsVeryRare)]

        publicIndicatorDataSeries resistance { get; set; }

        [Output("Sup", Color = Colors.Black, LineStyle = LineStyle.DotsVeryRare)]

        publicIndicatorDataSeries support { get; set; }

 

        publicdoubleres;

        publicdoublesup;

 

        privateMarketSeries Series;

 

 

        protectedoverridevoidInitialize()

        {

            // Initialize and create nested indicators

            Series = MarketSeries;

        }

 

        publicoverridevoidCalculate(intindex)

        {

            // Calculate value at specified index

            // Result[index] = ...

 

            var upline = (Series.Close.Maximum(range) + Series.High.Maximum(range)) / 2;

            var dnline = (Series.Close.Minimum(range) + Series.Low.Minimum(range)) / 2;

            resistance[index] = double.NaN;

            support[index] = double.NaN;

            if(resbarsconfirmed(upline, index) >= confirmations)

            {

                res = upline;

                ChartObjects.DrawLine("resline"+ upline.ToString(), Series.OpenTime[index], upline, Series.OpenTime[index - range], upline, Colors.DarkRed, 2, LineStyle.Solid);

            }

 

            if(supbarsconfirmed(dnline, index) >= confirmations)

            {

                sup = dnline;

                ChartObjects.DrawLine("supline"+ dnline.ToString(), Series.OpenTime[index], dnline, Series.OpenTime[index - range], dnline, Colors.DarkBlue, 2, LineStyle.Solid);

            }

 

        }

        privateintresbarsconfirmed(doubleline, intindex)

        {

            inttouches = 0;

            for(inti = index; i > index - range; i--)

            {

                if(Series.Low[i] < line && Series.High[i] >= line && Series.Close[i] < line)

                    touches += 1;

                if(Series.Close[i] > line)

                    touches = 0;

            }

            returntouches;

        }

        privateintsupbarsconfirmed(doubleline, intindex)

        {

            inttouches = 0;

            for(inti = index; i > index - range; i--)

            {

                if(Series.High[i] > line && Series.Low[i] <= line && Series.Close[i] > line)

                    touches += 1;

                if(Series.Close[i] < line)

                    touches = 0;

            }

            returntouches;

        }

    }

}

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
//+------------------------------------------------------------------+
//|                                                SupportResistance |
//|                                       Copyright © 2016, UCHE OBI |
//|                                               Developer:UCHE OBI |
//|                                                 Skype:  OBI.UCHE |
//|                                      email:ucheceleste@Gmail.com | 
//+------------------------------------------------------------------+
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 SupportResistance : Indicator
    {
        [Parameter(DefaultValue = 10)]
        public int range { get; set; }

        [Parameter(DefaultValue = 3)]
        public int confirmations { get; set; }

        [Output("Res", Color = Colors.Black, LineStyle = LineStyle.DotsVeryRare)]
        public IndicatorDataSeries resistance { get; set; }
        [Output("Sup", Color = Colors.Black, LineStyle = LineStyle.DotsVeryRare)]
        public IndicatorDataSeries support { get; set; }

        public double res;
        public double sup;

        private MarketSeries Series;


        protected override void Initialize()
        {
            // Initialize and create nested indicators
            Series = MarketSeries;
        }

        public override void Calculate(int index)
        {
            // Calculate value at specified index
            // Result[index] = ...

            var upline = (Series.Close.Maximum(range) + Series.High.Maximum(range)) / 2;
            var dnline = (Series.Close.Minimum(range) + Series.Low.Minimum(range)) / 2;
            resistance[index] = double.NaN;
            support[index] = double.NaN;
            if (resbarsconfirmed(upline, index) >= confirmations)
            {
                res = upline;
                ChartObjects.DrawLine("resline" + upline.ToString(), Series.OpenTime[index], upline, Series.OpenTime[index - range], upline, Colors.DarkRed, 2, LineStyle.Solid);
            }

            if (supbarsconfirmed(dnline, index) >= confirmations)
            {
                sup = dnline;
                ChartObjects.DrawLine("supline" + dnline.ToString(), Series.OpenTime[index], dnline, Series.OpenTime[index - range], dnline, Colors.DarkBlue, 2, LineStyle.Solid);
            }

        }
        private int resbarsconfirmed(double line, int index)
        {
            int touches = 0;
            for (int i = index; i > index - range; i--)
            {
                if (Series.Low[i] < line && Series.High[i] >= line && Series.Close[i] < line)
                    touches += 1;
                if (Series.Close[i] > line)
                    touches = 0;
            }
            return touches;
        }
        private int supbarsconfirmed(double line, int index)
        {
            int touches = 0;
            for (int i = index; i > index - range; i--)
            {
                if (Series.High[i] > line && Series.Low[i] <= line && Series.Close[i] > line)
                    touches += 1;
                if (Series.Close[i] < line)
                    touches = 0;
            }
            return touches;
        }
    }
}
Comments

salixo1753 - November 28, 2022 @ 00:18

Very useful script, started using it and works well

Salixo Cornela
Florist, Canada

SEOOO - November 29, 2022 @ 22:23

After working with this printing center, I was very satisfied with my recent printing. Being in the industry for years, I could say that it is really hard to find one with high quality of output at an affordable price. https://www.digitekprinting.com/poster-prints is the link to their site to save time and money as well.

gmrmessiu - December 01, 2022 @ 04:13

The post is very informative and useful. You and everyone are doing a great job. Go on. slither io

ljglmail - December 01, 2022 @ 17:14

Your writing is really informative, especially because it's so meaningful and updated. Thanks for sharing this wonderful post!

Your writing is really great. I’m so glad I read it. It kept me hooked the whole way through.

Thanks for this information. I really appreciate the information that you have provided.

https://www.mcd-voicex.com/
https://www.tellpopeyes.org/

0