Topics

Forum Topics not found

Replies

eacm8691
24 Mar 2025, 15:47 ( Updated at: 26 Mar 2025, 06:26 )

RE: RE: Previous Days/Weeks/Months Highs and Lows Indicator

hannanmumtaz01 said: 

Didnt work for me at all, did some cleanup / bugfixes, seems to be working now.

 

 

using cAlgo.API;using System;namespace cAlgo{    [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]    public class PreviousDayHighLow : Indicator    {        [Parameter("Show High", Group = "Previous Day H/L", DefaultValue = true)]        public bool PreDayHigh { get; set; }        [Parameter("Show Low", Group = "Previous Day H/L", DefaultValue = true)]        public bool PreDayLow { get; set; }        [Parameter("Color", Group = "Previous Day H/L", DefaultValue = ColorSelector.Pink)]        public ColorSelector PreDayLineColor { get; set; }        [Parameter("Style", Group = "Previous Day H/L", DefaultValue = LineSelector.Dots)]        public LineSelector PreDayLineStyle { get; set; }        [Parameter("Thickness", Group = "Previous Day H/L", MinValue = 1, DefaultValue = 1)]        public int PreDayThickness { get; set; }        [Parameter("Show High", Group = "Previous Week H/L", DefaultValue = false)]        public bool PreWeekHigh { get; set; }        [Parameter("Show Low", Group = "Previous Week H/L", DefaultValue = false)]        public bool PreWeekLow { get; set; }        [Parameter("Color", Group = "Previous Week H/L", DefaultValue = ColorSelector.Yellow)]        public ColorSelector PreWeekLineColor { get; set; }        [Parameter("Style", Group = "Previous Week H/L", DefaultValue = LineSelector.LinesDots)]        public LineSelector PreWeekLineStyle { get; set; }        [Parameter("Thickness", Group = "Previous Week H/L", MinValue = 1, DefaultValue = 1)]        public int PreWeekThickness { get; set; }        [Parameter("Show High", Group = "Previous Month H/L", DefaultValue = false)]        public bool PreMonthHigh { get; set; }        [Parameter("Show Low", Group = "Previous Month H/L", DefaultValue = false)]        public bool PreMonthLow { get; set; }        [Parameter("Color", Group = "Previous Month H/L", DefaultValue = ColorSelector.Purple)]        public ColorSelector PreMonthLineColor { get; set; }        [Parameter("Style", Group = "Previous Month H/L", DefaultValue = LineSelector.Solid)]        public LineSelector PreMonthLineStyle { get; set; }        [Parameter("Thickness", Group = "Previous Month H/L", MinValue = 1, DefaultValue = 1)]        public int PreMonthThickness { get; set; }        [Parameter("Hue", Group = "Global", DefaultValue = HueSelector.Main)]        public HueSelector PreHue { get; set; }        [Parameter("Start Hour", Group = "Global", DefaultValue = 12, MinValue = 0, MaxValue = 23, Step = 1)]        public int StartTimeHour { get; set; }        [Parameter("UTC adjustment (-/+)", Group = "Global", DefaultValue = 8, MinValue = -12, MaxValue = 14, Step = 1)]        public int Utc { get; set; }        private Bars _week, _day, _month;        private IndicatorDataSeries _indexM, _indexD, _indexW;        public enum HueSelector        {            Main,            Light,            Dark        }        public enum LineSelector        {            Solid,            Lines,            LinesDots,            Dots,            DotsRare,            DotsVeryRare        }        public enum ColorSelector        {            Default,            White,            Black,            Gray,            Blue,            Cyan,            Red,            Pink,            Green,            Orange,            Yellow,            Purple        }        protected override void Initialize()        {            System.Diagnostics.Debugger.Launch();            _week = MarketData.GetBars(TimeFrame.Weekly);            _day = MarketData.GetBars(TimeFrame.Daily);            _month = MarketData.GetBars(TimeFrame.Monthly);            _indexW = CreateDataSeries();            _indexD = CreateDataSeries();            _indexM = CreateDataSeries();        }        public override void Calculate(int index)        {            var indexOpenTime = Bars.OpenTimes[index];            CalculateDailyHighLows(index, indexOpenTime);            CalculateWeeklyHighLows(index, indexOpenTime);            CalculateMonthlyHighLows(index, indexOpenTime);        }        private void CalculateMonthlyHighLows(int index, DateTime indexOpenTime)        {            if (!PreMonthHigh && !PreMonthLow) return;            var monthlyIndex = _month.OpenTimes.GetIndexByTime(indexOpenTime);            _indexM[index] = monthlyIndex > 0 ? monthlyIndex : _indexM[index - 1];            var nameHigh = "Month High" + _indexM[index];            var nameLow = "Month Low" + _indexM[index];            var indexStart = (int)_indexM[index];            var start = _month.OpenTimes[indexStart - 1];            var stop = Bars.OpenTimes[index];            var high = _month.HighPrices[indexStart - 1];            var low = _month.LowPrices[indexStart - 1];            var clr = GetColor(PreMonthLineColor, PreHue);            var lns = GetLineStyle(PreMonthLineStyle);            if (double.IsNaN(high) || double.IsNaN(low)) return;            if (PreMonthHigh)                Chart.DrawTrendLine(nameHigh, start, high, stop, high, clr, PreMonthThickness, lns);            if (PreMonthLow)                Chart.DrawTrendLine(nameLow, start, low, stop, low, clr, PreMonthThickness, lns);        }        private void CalculateWeeklyHighLows(int index, DateTime indexOpenTime)        {            if (!PreWeekHigh && !PreWeekLow) return;            var weeklyIndex = _week.OpenTimes.GetIndexByTime(indexOpenTime);            _indexW[index] = weeklyIndex > 0 ? weeklyIndex : _indexW[index - 1];            var nameHigh = "Week High" + _indexW[index];            var nameLow = "Week Low" + _indexW[index];            var indexStart = (int)_indexW[index];            var start = _week.OpenTimes[indexStart - 1];            var stop = Bars.OpenTimes[index];            var high = _week.HighPrices[indexStart - 1];            var low = _week.LowPrices[indexStart - 1];            var clr = GetColor(PreWeekLineColor, PreHue);            var lns = GetLineStyle(PreWeekLineStyle);            if (double.IsNaN(high) || double.IsNaN(low)) return;            if (PreWeekHigh)                Chart.DrawTrendLine(nameHigh, start, high, stop, high, clr, PreWeekThickness, lns);            if (PreWeekLow)                Chart.DrawTrendLine(nameLow, start, low, stop, low, clr, PreWeekThickness, lns);        }        private void CalculateDailyHighLows(int index, DateTime indexOpenTime)        {            if (!PreDayHigh && !PreDayLow) return;            var dailyIndex = _day.OpenTimes.GetIndexByTime(indexOpenTime);            _indexD[index] = dailyIndex > 0 ? dailyIndex : _indexD[index - 1];            var nameHigh = "Day High" + _indexD[index];            var nameLow = "Day Low" + _indexD[index];            var indexStart = (int)_indexD[index];            var startHour = StartTimeHour - Utc;            DateTime lineStart;            switch (startHour)            {                case >= 24:                    startHour -= 24;                    lineStart = new DateTime(Bars.OpenTimes[index].Year, Bars.OpenTimes[index].Month, Bars.OpenTimes[index].Day, startHour, 0, 0);                    break;                case <= 0:                    startHour += 24;                    lineStart = new DateTime(Bars.OpenTimes[index].Year, Bars.OpenTimes[index].Month, Bars.OpenTimes[index].Day, startHour, 0, 0);                    break;                default:                    lineStart = new DateTime(Bars.OpenTimes[index].Year, Bars.OpenTimes[index].Month, Bars.OpenTimes[index].Day, startHour, 0, 0);                    break;            }            // line length            var timeSpan = new TimeSpan(23, 59, 59);            var lineStop = lineStart + timeSpan;            // line height            var dayHighPrice = _day.HighPrices[indexStart - 1];            var dayLowPrice = _day.LowPrices[indexStart - 1];            // line style            var color = GetColor(PreDayLineColor, PreHue);            var lineStyle = GetLineStyle(PreDayLineStyle);            if (double.IsNaN(dayHighPrice) || double.IsNaN(dayLowPrice)) return;            if (PreDayHigh)                Chart.DrawTrendLine(nameHigh, lineStart, dayHighPrice, lineStop, dayHighPrice, color, PreDayThickness, lineStyle);            if (PreDayLow)                Chart.DrawTrendLine(nameLow, lineStart, dayLowPrice, lineStop, dayLowPrice, color, PreDayThickness, lineStyle);        }        private Color GetColor(ColorSelector color, HueSelector hue)        {            Color result;            switch (color)            {                case ColorSelector.Black:                    {                        result = Color.Black;                    }                    break;                case ColorSelector.White:                    {                        result = Color.White;                    }                    break;                case ColorSelector.Gray:                    {                        if (hue.Equals(HueSelector.Dark))                        {                            result = Color.DarkGray;                        }                        else if (hue.Equals(HueSelector.Light))                        {                            result = Color.LightGray;                        }                        else                        {                            result = Color.Gray;                        }                    }                    break;                case ColorSelector.Blue:                    {                        if (hue.Equals(HueSelector.Dark))                        {                            result = Color.DarkBlue;                        }                        else if (hue.Equals(HueSelector.Light))                        {                            result = Color.LightBlue;                        }                        else                        {                            result = Color.Blue;                        }                    }                    break;                case ColorSelector.Cyan:                    {                        if (hue.Equals(HueSelector.Dark))                        {                            result = Color.DarkCyan;                        }                        else if (hue.Equals(HueSelector.Light))                        {                            result = Color.LightCyan;                        }                        else                        {                            result = Color.Cyan;                        }                    }                    break;                case ColorSelector.Red:                    {                        if (hue.Equals(HueSelector.Dark))                        {                            result = Color.DarkRed;                        }                        else if (hue.Equals(HueSelector.Light))                        {                            result = Color.OrangeRed;                        }                        else                        {                            result = Color.Red;                        }                    }                    break;                case ColorSelector.Pink:                    {                        if (hue.Equals(HueSelector.Dark))                        {                            result = Color.DarkMagenta;                        }                        else if (hue.Equals(HueSelector.Light))                        {                            result = Color.LightPink;                        }                        else                        {                            result = Color.Pink;                        }                    }                    break;                case ColorSelector.Green:                    {                        if (hue.Equals(HueSelector.Dark))                        {                            result = Color.DarkGreen;                        }                        else if (hue.Equals(HueSelector.Light))                        {                            result = Color.LightGreen;                        }                        else                        {                            result = Color.Green;                        }                    }                    break;                case ColorSelector.Orange:                    {                        if (hue.Equals(HueSelector.Dark))                        {                            result = Color.DarkOrange;                        }                        else if (hue.Equals(HueSelector.Light))                        {                            result = Color.Orange;                        }                        else                        {                            result = Color.Orange;                        }                    }                    break;                case ColorSelector.Yellow:                    {                        if (hue.Equals(HueSelector.Dark))                        {                            result = Color.Gold;                        }                        else if (hue.Equals(HueSelector.Light))                        {                            result = Color.LightYellow;                        }                        else                        {                            result = Color.Yellow;                        }                    }                    break;                case ColorSelector.Purple:                    {                        if (hue.Equals(HueSelector.Dark))                        {                            result = Color.DarkViolet;                        }                        else if (hue.Equals(HueSelector.Light))                        {                            result = Color.Violet;                        }                        else                        {                            result = Color.Purple;                        }                    }                    break;                case ColorSelector.Default:                    {                        result = Application.ColorTheme.Equals(ColorTheme.Dark) ? Color.White : Color.Black;                    }                    break;                default:                    {                        result = Application.ColorTheme.Equals(ColorTheme.Dark) ? Color.White : Color.Black;                    }                    break;            }            return result;        }        private static LineStyle GetLineStyle(LineSelector line) =>            line switch            {                LineSelector.Solid => LineStyle.Solid,                LineSelector.Lines => LineStyle.Lines,                LineSelector.LinesDots => LineStyle.LinesDots,                LineSelector.Dots => LineStyle.Dots,                LineSelector.DotsRare => LineStyle.DotsRare,                LineSelector.DotsVeryRare => LineStyle.DotsVeryRare,                _ => LineStyle.Solid            };    }}

fix this one there where some visual errors:

 

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

namespace cAlgo
{
   [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)]
   public class PreviousDayHighLow : Indicator
   {
       // ---------------------------------
       // Parámetros para el DÍA ANTERIOR
       // ---------------------------------
       [Parameter("Show High", Group = "Previous Day H/L", DefaultValue = true)]
       public bool PreDayHigh { get; set; }

       [Parameter("Show Low", Group = "Previous Day H/L", DefaultValue = true)]
       public bool PreDayLow { get; set; }

       [Parameter("Color", Group = "Previous Day H/L", DefaultValue = ColorSelector.Pink)]
       public ColorSelector PreDayLineColor { get; set; }

       [Parameter("Style", Group = "Previous Day H/L", DefaultValue = LineSelector.Dots)]
       public LineSelector PreDayLineStyle { get; set; }

       [Parameter("Thickness", Group = "Previous Day H/L", MinValue = 1, DefaultValue = 1)]
       public int PreDayThickness { get; set; }

       // ---------------------------------
       // Parámetros para la SEMANA ANTERIOR
       // ---------------------------------
       [Parameter("Show High", Group = "Previous Week H/L", DefaultValue = true)]
       public bool PreWeekHigh { get; set; }

       [Parameter("Show Low", Group = "Previous Week H/L", DefaultValue = true)]
       public bool PreWeekLow { get; set; }

       [Parameter("Color", Group = "Previous Week H/L", DefaultValue = ColorSelector.Yellow)]
       public ColorSelector PreWeekLineColor { get; set; }

       [Parameter("Style", Group = "Previous Week H/L", DefaultValue = LineSelector.LinesDots)]
       public LineSelector PreWeekLineStyle { get; set; }

       [Parameter("Thickness", Group = "Previous Week H/L", MinValue = 1, DefaultValue = 1)]
       public int PreWeekThickness { get; set; }

       // ---------------------------------
       // Parámetros para el MES ANTERIOR
       // ---------------------------------
       [Parameter("Show High", Group = "Previous Month H/L", DefaultValue = true)]
       public bool PreMonthHigh { get; set; }

       [Parameter("Show Low", Group = "Previous Month H/L", DefaultValue = true)]
       public bool PreMonthLow { get; set; }

       [Parameter("Color", Group = "Previous Month H/L", DefaultValue = ColorSelector.Purple)]
       public ColorSelector PreMonthLineColor { get; set; }

       [Parameter("Style", Group = "Previous Month H/L", DefaultValue = LineSelector.Solid)]
       public LineSelector PreMonthLineStyle { get; set; }

       [Parameter("Thickness", Group = "Previous Month H/L", MinValue = 1, DefaultValue = 1)]
       public int PreMonthThickness { get; set; }

       // ---------------------------------
       // Parámetros Globales
       // ---------------------------------
       [Parameter("Hue", Group = "Global", DefaultValue = HueSelector.Main)]
       public HueSelector PreHue { get; set; }

       [Parameter("Start Hour (Daily)", Group = "Global", DefaultValue = 12, MinValue = 0, MaxValue = 23, Step = 1)]
       public int StartTimeHour { get; set; }

       [Parameter("UTC adjustment (Daily)", Group = "Global", DefaultValue = -5, MinValue = -12, MaxValue = 14, Step = 1)]
       public int Utc { get; set; }

       private Bars _day;
       private Bars _week;
       private Bars _month;

       // Enums para color y estilo
       public enum HueSelector
       {
           Main,
           Light,
           Dark
       }

       public enum LineSelector
       {
           Solid,
           Lines,
           LinesDots,
           Dots,
           DotsRare,
           DotsVeryRare
       }

       public enum ColorSelector
       {
           Default,
           White,
           Black,
           Gray,
           Blue,
           Cyan,
           Red,
           Pink,
           Green,
           Orange,
           Yellow,
           Purple
       }

       protected override void Initialize()
       {
           // Obtenemos la serie diaria, semanal y mensual
           _day = MarketData.GetBars(TimeFrame.Daily);
           _week = MarketData.GetBars(TimeFrame.Weekly);
           _month = MarketData.GetBars(TimeFrame.Monthly);
       }

       public override void Calculate(int index)
       {
           // Mostramos solo el día anterior más reciente
           CalculateDailyHighLows(index);

           // Mostramos solo la semana anterior más reciente
           CalculateWeeklyHighLows(index);

           // Mostramos solo el mes anterior más reciente
           CalculateMonthlyHighLows(index);
       }

       // --------------------------------------------------------------------
       // 1) CÁLCULO DEL DÍA ANTERIOR (SOLO el más reciente)
       // --------------------------------------------------------------------
       private void CalculateDailyHighLows(int index)
       {
           if (!PreDayHigh && !PreDayLow)
               return;

           DateTime indexOpenTime = Bars.OpenTimes[index];
           int dailyIndex = _day.OpenTimes.GetIndexByTime(indexOpenTime);

           // Se necesita al menos 1 día anterior
           if (dailyIndex < 1)
               return;

           int prevDayIndex = dailyIndex - 1;

           // Borramos líneas anteriores para no acumular
           Chart.RemoveObject("Day High");
           Chart.RemoveObject("Day Low");

           // Ajustamos la hora de inicio según parámetros
           DateTime prevDayOpenTime = _day.OpenTimes[prevDayIndex];
           int startHour = StartTimeHour - Utc;

           // Normalizamos startHour si sale del rango 0-23
           if (startHour >= 24) startHour -= 24;
           else if (startHour < 0) startHour += 24;

           DateTime lineStart = new DateTime(prevDayOpenTime.Year, prevDayOpenTime.Month, prevDayOpenTime.Day, startHour, 0, 0);
           // Duración de un día completo
           TimeSpan timeSpan = new TimeSpan(23, 59, 59);
           DateTime lineStop = lineStart + timeSpan;

           // Altos y bajos del día anterior
           double dayHighPrice = _day.HighPrices[prevDayIndex];
           double dayLowPrice = _day.LowPrices[prevDayIndex];

           if (double.IsNaN(dayHighPrice) || double.IsNaN(dayLowPrice))
               return;

           // Dibujamos
           Color color = GetColor(PreDayLineColor, PreHue);
           LineStyle lineStyle = GetLineStyle(PreDayLineStyle);

           if (PreDayHigh)
               Chart.DrawTrendLine("Day High", lineStart, dayHighPrice, lineStop, dayHighPrice, color, PreDayThickness, lineStyle);

           if (PreDayLow)
               Chart.DrawTrendLine("Day Low", lineStart, dayLowPrice, lineStop, dayLowPrice, color, PreDayThickness, lineStyle);
       }

       // --------------------------------------------------------------------
       // 2) CÁLCULO DE LA SEMANA ANTERIOR (SOLO la más reciente)
       // --------------------------------------------------------------------
       private void CalculateWeeklyHighLows(int index)
       {
           if (!PreWeekHigh && !PreWeekLow)
               return;

           DateTime indexOpenTime = Bars.OpenTimes[index];
           int weeklyIndex = _week.OpenTimes.GetIndexByTime(indexOpenTime);

           // Se necesita al menos 1 semana anterior
           if (weeklyIndex < 1)
               return;

           int prevWeekIndex = weeklyIndex - 1;

           // Borramos líneas anteriores para no acumular
           Chart.RemoveObject("Week High");
           Chart.RemoveObject("Week Low");

           // Obtenemos los altos y bajos de la semana anterior
           double weekHighPrice = _week.HighPrices[prevWeekIndex];
           double weekLowPrice = _week.LowPrices[prevWeekIndex];

           if (double.IsNaN(weekHighPrice) || double.IsNaN(weekLowPrice))
               return;

           // Definimos el inicio de la semana anterior
           DateTime prevWeekOpenTime = _week.OpenTimes[prevWeekIndex];
           // Definimos el final de esa semana (justo antes de la apertura de la siguiente)
           DateTime nextWeekOpenTime = _week.OpenTimes[weeklyIndex];
           DateTime lineStop = nextWeekOpenTime.AddSeconds(-1);

           // Dibujamos
           Color color = GetColor(PreWeekLineColor, PreHue);
           LineStyle lineStyle = GetLineStyle(PreWeekLineStyle);

           if (PreWeekHigh)
               Chart.DrawTrendLine("Week High", prevWeekOpenTime, weekHighPrice, lineStop, weekHighPrice, color, PreWeekThickness, lineStyle);

           if (PreWeekLow)
               Chart.DrawTrendLine("Week Low", prevWeekOpenTime, weekLowPrice, lineStop, weekLowPrice, color, PreWeekThickness, lineStyle);
       }

       // --------------------------------------------------------------------
       // 3) CÁLCULO DEL MES ANTERIOR (SOLO el más reciente)
       // --------------------------------------------------------------------
       private void CalculateMonthlyHighLows(int index)
       {
           if (!PreMonthHigh && !PreMonthLow)
               return;

           DateTime indexOpenTime = Bars.OpenTimes[index];
           int monthlyIndex = _month.OpenTimes.GetIndexByTime(indexOpenTime);

           // Se necesita al menos 1 mes anterior
           if (monthlyIndex < 1)
               return;

           int prevMonthIndex = monthlyIndex - 1;

           // Borramos líneas anteriores para no acumular
           Chart.RemoveObject("Month High");
           Chart.RemoveObject("Month Low");

           // Obtenemos los altos y bajos del mes anterior
           double monthHighPrice = _month.HighPrices[prevMonthIndex];
           double monthLowPrice = _month.LowPrices[prevMonthIndex];

           if (double.IsNaN(monthHighPrice) || double.IsNaN(monthLowPrice))
               return;

           // Inicio del mes anterior
           DateTime prevMonthOpenTime = _month.OpenTimes[prevMonthIndex];
           // Fin del mes anterior (un segundo antes de la apertura del siguiente)
           DateTime nextMonthOpenTime = _month.OpenTimes[monthlyIndex];
           DateTime lineStop = nextMonthOpenTime.AddSeconds(-1);

           // Dibujamos
           Color color = GetColor(PreMonthLineColor, PreHue);
           LineStyle lineStyle = GetLineStyle(PreMonthLineStyle);

           if (PreMonthHigh)
               Chart.DrawTrendLine("Month High", prevMonthOpenTime, monthHighPrice, lineStop, monthHighPrice, color, PreMonthThickness, lineStyle);

           if (PreMonthLow)
               Chart.DrawTrendLine("Month Low", prevMonthOpenTime, monthLowPrice, lineStop, monthLowPrice, color, PreMonthThickness, lineStyle);
       }

       // ----------------------------------------------------
       // Métodos auxiliares para colores y estilos de línea
       // ----------------------------------------------------
       private Color GetColor(ColorSelector color, HueSelector hue)
       {
           switch (color)
           {
               case ColorSelector.Black:
                   return Color.Black;
               case ColorSelector.White:
                   return Color.White;
               case ColorSelector.Gray:
                   if (hue == HueSelector.Dark) return Color.DarkGray;
                   if (hue == HueSelector.Light) return Color.LightGray;
                   return Color.Gray;
               case ColorSelector.Blue:
                   if (hue == HueSelector.Dark) return Color.DarkBlue;
                   if (hue == HueSelector.Light) return Color.LightBlue;
                   return Color.Blue;
               case ColorSelector.Cyan:
                   if (hue == HueSelector.Dark) return Color.DarkCyan;
                   if (hue == HueSelector.Light) return Color.LightCyan;
                   return Color.Cyan;
               case ColorSelector.Red:
                   if (hue == HueSelector.Dark) return Color.DarkRed;
                   if (hue == HueSelector.Light) return Color.OrangeRed;
                   return Color.Red;
               case ColorSelector.Pink:
                   if (hue == HueSelector.Dark) return Color.DarkMagenta;
                   if (hue == HueSelector.Light) return Color.LightPink;
                   return Color.Pink;
               case ColorSelector.Green:
                   if (hue == HueSelector.Dark) return Color.DarkGreen;
                   if (hue == HueSelector.Light) return Color.LightGreen;
                   return Color.Green;
               case ColorSelector.Orange:
                   if (hue == HueSelector.Dark) return Color.DarkOrange;
                   if (hue == HueSelector.Light) return Color.Orange;
                   return Color.Orange;
               case ColorSelector.Yellow:
                   if (hue == HueSelector.Dark) return Color.Gold;
                   if (hue == HueSelector.Light) return Color.LightYellow;
                   return Color.Yellow;
               case ColorSelector.Purple:
                   if (hue == HueSelector.Dark) return Color.DarkViolet;
                   if (hue == HueSelector.Light) return Color.Violet;
                   return Color.Purple;
               case ColorSelector.Default:
               default:
                   return Application.ColorTheme == ColorTheme.Dark ? Color.White : Color.Black;
           }
       }

       private static LineStyle GetLineStyle(LineSelector line)
       {
           return line switch
           {
               LineSelector.Solid => LineStyle.Solid,
               LineSelector.Lines => LineStyle.Lines,
               LineSelector.LinesDots => LineStyle.LinesDots,
               LineSelector.Dots => LineStyle.Dots,
               LineSelector.DotsRare => LineStyle.DotsRare,
               LineSelector.DotsVeryRare => LineStyle.DotsVeryRare,
               _ => LineStyle.Solid,
           };
       }
   }
}
 


@eacm8691