cxc_g
cxc_g's avatar

Info

Username:cxc_g
Name:cxc_g
Member since: 23 Nov 2022

About

None

Signature

None
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.
SupportResistance
  4
  0
  243
by cxc_g
free  23 Nov 2022
//+------------------------------------------------------------------+ //|                                                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;         }     } }
Warning! Executing cBots downloaded from this section may result in loss of funds. Use them at your own risk.

No uploaded.