Hello friends, this is the indicator that I have designed to manage the sessions. But it seems that it does not work properly in Mac operating system. In case I wrote it with .NET 6 and no error or warning is observed during compilation. How can I fix the indicator problem?
using System; using System.Collections.Generic; using System.Linq; using System.Text; using cAlgo.API; using cAlgo.API.Collections; using cAlgo.API.Indicators; using cAlgo.API.Internals; using System.Globalization; namespace cAlgo { [Indicator(AccessRights = AccessRights.FullAccess, IsOverlay = true, TimeZone = TimeZones.UTC)] public class TradingSessions : Indicator { [Parameter("Version:", DefaultValue = "1.0.1")] public string Version { get; set; }
[Parameter("Show for how many days", Group = "Sessions", DefaultValue = 15, MinValue = 0)] public int Back_days { get; set; } [Parameter("Filled Zones", DefaultValue = true, Group = "Sessions")] public bool Filled_Zones { get; set; } [Parameter("Show Labels", DefaultValue = true, Group = "Sessions")] public bool Show_Labels { get; set; } [Parameter("Infinitie range", DefaultValue = Infinite_Range.None, Group = "Sessions")] public Infinite_Range InfiniteRange { get; set; } public enum Infinite_Range { Up, Down, Both, None }
[Parameter("Show Session 1", DefaultValue = true, Group = "Session 1")] public bool S1_Show { get; set; } [Parameter("Session Label", DefaultValue = "Sydney", Group = "Session 1")] public string S1_Label { get; set; } [Parameter("Start time", DefaultValue = "21:00", Group = "Session 1")] public string S1_open { get; set; } [Parameter("End time", DefaultValue = "06:00", Group = "Session 1")] public string S1_close { get; set; } [Parameter("Color", Group = "Session 1", DefaultValue = "#20BEBF00")] public Color S1_Color { get; set; } [Parameter("Line Style", Group = "Session 1", DefaultValue = LineStyle.DotsRare)] public LineStyle S1_LineStyle { get; set; }
[Parameter("Show Session 2", DefaultValue = true, Group = "Session 2")] public bool S2_Show { get; set; } [Parameter("Session Label", DefaultValue = "Tokyo", Group = "Session 2")] public string S2_Label { get; set; } [Parameter("Start time", DefaultValue = "00:00", Group = "Session 2")] public string S2_open { get; set; } [Parameter("End time", DefaultValue = "09:00", Group = "Session 2")] public string S2_close { get; set; } [Parameter("Color", Group = "Session 2", DefaultValue = "#2001AF50")] public Color S2_Color { get; set; } [Parameter("Line Style", Group = "Session 2", DefaultValue = LineStyle.DotsRare)] public LineStyle S2_LineStyle { get; set; }
[Parameter("Show Session 3", DefaultValue = true, Group = "Session 3")] public bool S3_Show { get; set; } [Parameter("Session Label", DefaultValue = "London", Group = "Session 3")] public string S3_Label { get; set; } [Parameter("Start time", DefaultValue = "07:00", Group = "Session 3")] public string S3_open { get; set; } [Parameter("End time", DefaultValue = "16:00", Group = "Session 3")] public string S3_close { get; set; } [Parameter("Color", Group = "Session 3", DefaultValue = "#2033C1F3")] public Color S3_Color { get; set; } [Parameter("Line Style", Group = "Session 3", DefaultValue = LineStyle.DotsRare)] public LineStyle S3_LineStyle { get; set; }
[Parameter("Show Session 4", DefaultValue = true, Group = "Session 4")] public bool S4_Show { get; set; } [Parameter("Session Label", DefaultValue = "New York", Group = "Session 4")] public string S4_Label { get; set; } [Parameter("Start time", DefaultValue = "13:00", Group = "Session 4")] public string S4_open { get; set; } [Parameter("End time", DefaultValue = "22:00", Group = "Session 4")] public string S4_close { get; set; } [Parameter("Color", Group = "Session 4", DefaultValue = "#20FF3334")] public Color S4_Color { get; set; } [Parameter("Line Style", Group = "Session 4", DefaultValue = LineStyle.DotsRare)] public LineStyle S4_LineStyle { get; set; }
[Parameter("Show Session 5", DefaultValue = false, Group = "Session 5")] public bool S5_Show { get; set; } [Parameter("Session Label", DefaultValue = "", Group = "Session 5")] public string S5_Label { get; set; } [Parameter("Start time", DefaultValue = "00:00", Group = "Session 5")] public string S5_open { get; set; } [Parameter("End time", DefaultValue = "09:00", Group = "Session 5")] public string S5_close { get; set; } [Parameter("Color", Group = "Session 5", DefaultValue = "#75939695")] public Color S5_Color { get; set; } [Parameter("Line Style", Group = "Session 5", DefaultValue = LineStyle.DotsRare)] public LineStyle S5_LineStyle { get; set; }
public List<Session> _sessions = new();
protected override void Initialize() { if (Bars.TimeFrame > TimeFrame.Hour4) return;
if (S1_Show && S1_Label != "") _sessions.Add(new Session { name = S1_Label, Open = TimeSpan.Parse(S1_open, CultureInfo.InvariantCulture), Close = TimeSpan.Parse(S1_close), Color = S1_Color, LineStyle = S1_LineStyle }); if (S2_Show && S1_Label != "") _sessions.Add(new Session { name = S2_Label, Open = TimeSpan.Parse(S2_open, CultureInfo.InvariantCulture), Close = TimeSpan.Parse(S2_close), Color = S2_Color, LineStyle = S2_LineStyle }); if (S3_Show && S1_Label != "") _sessions.Add(new Session { name = S3_Label, Open = TimeSpan.Parse(S3_open, CultureInfo.InvariantCulture), Close = TimeSpan.Parse(S3_close), Color = S3_Color, LineStyle = S3_LineStyle }); if (S4_Show && S1_Label != "") _sessions.Add(new Session { name = S4_Label, Open = TimeSpan.Parse(S4_open, CultureInfo.InvariantCulture), Close = TimeSpan.Parse(S4_close), Color = S4_Color, LineStyle = S4_LineStyle }); if (S5_Show && S1_Label != "") _sessions.Add(new Session { name = S5_Label, Open = TimeSpan.Parse(S5_open, CultureInfo.InvariantCulture), Close = TimeSpan.Parse(S5_close), Color = S5_Color, LineStyle = S5_LineStyle });
foreach (var session in _sessions) { Draw_rect(session.name, session.Open, session.Close, session.Color, session.LineStyle); } var bars_m1 = MarketData.GetBars(TimeFrame.Minute, Symbol.Name); bars_m1.BarOpened += bars_m1_BarOpened;
var Current_bars = MarketData.GetBars(Bars.TimeFrame, Symbol.Name); Current_bars.BarOpened += Current_bars_BarOpened; ; }
public class Session { public string name { get; set; } public TimeSpan Open { get; set; } public TimeSpan Close { get; set; } public Color Color { get; set; } public LineStyle LineStyle { get; set; } } }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using cAlgo.API; using cAlgo.API.Collections; using cAlgo.API.Indicators; using cAlgo.API.Internals; using System.Globalization; namespace cAlgo { [Indicator(AccessRights = AccessRights.FullAccess, IsOverlay = true, TimeZone = TimeZones.UTC)] public class TradingSessions : Indicator { [Parameter("Version:", DefaultValue = "1.0.1")] public string Version { get; set; }
[Parameter("Show for how many days", Group = "Sessions", DefaultValue = 15, MinValue = 0)] public int Back_days { get; set; } [Parameter("Filled Zones", DefaultValue = true, Group = "Sessions")] public bool Filled_Zones { get; set; } [Parameter("Show Labels", DefaultValue = true, Group = "Sessions")] public bool Show_Labels { get; set; } [Parameter("Infinitie range", DefaultValue = Infinite_Range.None, Group = "Sessions")] public Infinite_Range InfiniteRange { get; set; } public enum Infinite_Range { Up, Down, Both, None }
[Parameter("Show Session 1", DefaultValue = true, Group = "Session 1")] public bool S1_Show { get; set; } [Parameter("Session Label", DefaultValue = "Sydney", Group = "Session 1")] public string S1_Label { get; set; } [Parameter("Start time", DefaultValue = "21:00", Group = "Session 1")] public string S1_open { get; set; } [Parameter("End time", DefaultValue = "06:00", Group = "Session 1")] public string S1_close { get; set; } [Parameter("Color", Group = "Session 1", DefaultValue = "#20BEBF00")] public Color S1_Color { get; set; } [Parameter("Line Style", Group = "Session 1", DefaultValue = LineStyle.DotsRare)] public LineStyle S1_LineStyle { get; set; }
[Parameter("Show Session 2", DefaultValue = true, Group = "Session 2")] public bool S2_Show { get; set; } [Parameter("Session Label", DefaultValue = "Tokyo", Group = "Session 2")] public string S2_Label { get; set; } [Parameter("Start time", DefaultValue = "00:00", Group = "Session 2")] public string S2_open { get; set; } [Parameter("End time", DefaultValue = "09:00", Group = "Session 2")] public string S2_close { get; set; } [Parameter("Color", Group = "Session 2", DefaultValue = "#2001AF50")] public Color S2_Color { get; set; } [Parameter("Line Style", Group = "Session 2", DefaultValue = LineStyle.DotsRare)] public LineStyle S2_LineStyle { get; set; }
[Parameter("Show Session 3", DefaultValue = true, Group = "Session 3")] public bool S3_Show { get; set; } [Parameter("Session Label", DefaultValue = "London", Group = "Session 3")] public string S3_Label { get; set; } [Parameter("Start time", DefaultValue = "07:00", Group = "Session 3")] public string S3_open { get; set; } [Parameter("End time", DefaultValue = "16:00", Group = "Session 3")] public string S3_close { get; set; } [Parameter("Color", Group = "Session 3", DefaultValue = "#2033C1F3")] public Color S3_Color { get; set; } [Parameter("Line Style", Group = "Session 3", DefaultValue = LineStyle.DotsRare)] public LineStyle S3_LineStyle { get; set; }
[Parameter("Show Session 4", DefaultValue = true, Group = "Session 4")] public bool S4_Show { get; set; } [Parameter("Session Label", DefaultValue = "New York", Group = "Session 4")] public string S4_Label { get; set; } [Parameter("Start time", DefaultValue = "13:00", Group = "Session 4")] public string S4_open { get; set; } [Parameter("End time", DefaultValue = "22:00", Group = "Session 4")] public string S4_close { get; set; } [Parameter("Color", Group = "Session 4", DefaultValue = "#20FF3334")] public Color S4_Color { get; set; } [Parameter("Line Style", Group = "Session 4", DefaultValue = LineStyle.DotsRare)] public LineStyle S4_LineStyle { get; set; }
[Parameter("Show Session 5", DefaultValue = false, Group = "Session 5")] public bool S5_Show { get; set; } [Parameter("Session Label", DefaultValue = "", Group = "Session 5")] public string S5_Label { get; set; } [Parameter("Start time", DefaultValue = "00:00", Group = "Session 5")] public string S5_open { get; set; } [Parameter("End time", DefaultValue = "09:00", Group = "Session 5")] public string S5_close { get; set; } [Parameter("Color", Group = "Session 5", DefaultValue = "#75939695")] public Color S5_Color { get; set; } [Parameter("Line Style", Group = "Session 5", DefaultValue = LineStyle.DotsRare)] public LineStyle S5_LineStyle { get; set; }
public List<Session> _sessions = new();
protected override void Initialize() { if (Bars.TimeFrame > TimeFrame.Hour4) return;
if (S1_Show && S1_Label != "") _sessions.Add(new Session { name = S1_Label, Open = TimeSpan.Parse(S1_open, CultureInfo.InvariantCulture), Close = TimeSpan.Parse(S1_close), Color = S1_Color, LineStyle = S1_LineStyle }); if (S2_Show && S1_Label != "") _sessions.Add(new Session { name = S2_Label, Open = TimeSpan.Parse(S2_open, CultureInfo.InvariantCulture), Close = TimeSpan.Parse(S2_close), Color = S2_Color, LineStyle = S2_LineStyle }); if (S3_Show && S1_Label != "") _sessions.Add(new Session { name = S3_Label, Open = TimeSpan.Parse(S3_open, CultureInfo.InvariantCulture), Close = TimeSpan.Parse(S3_close), Color = S3_Color, LineStyle = S3_LineStyle }); if (S4_Show && S1_Label != "") _sessions.Add(new Session { name = S4_Label, Open = TimeSpan.Parse(S4_open, CultureInfo.InvariantCulture), Close = TimeSpan.Parse(S4_close), Color = S4_Color, LineStyle = S4_LineStyle }); if (S5_Show && S1_Label != "") _sessions.Add(new Session { name = S5_Label, Open = TimeSpan.Parse(S5_open, CultureInfo.InvariantCulture), Close = TimeSpan.Parse(S5_close), Color = S5_Color, LineStyle = S5_LineStyle });
foreach (var session in _sessions) { Draw_rect(session.name, session.Open, session.Close, session.Color, session.LineStyle); } var bars_m1 = MarketData.GetBars(TimeFrame.Minute, Symbol.Name); bars_m1.BarOpened += bars_m1_BarOpened;
var Current_bars = MarketData.GetBars(Bars.TimeFrame, Symbol.Name); Current_bars.BarOpened += Current_bars_BarOpened; ; }
public class Session { public string name { get; set; } public TimeSpan Open { get; set; } public TimeSpan Close { get; set; } public Color Color { get; set; } public LineStyle LineStyle { get; set; } } }
Hi there,
It looks fine on our side. If the issue persists for the user, please ask him send us some troubleshooting info and quote the link to this discussion.
PanagiotisCharalampous
24 Oct 2024, 11:30
Hi there,
Can you explain what is the exact problem?
Best regards,
Panagiotis
@PanagiotisCharalampous