cross hair sync tool: can someone fix it?
cross hair sync tool: can someone fix it?
12 Dec 2019, 14:12
Hello.
I downloaded a custom indicator tool called "crosshair sync". This tool is not natively present on the platform while in other platforms is a must.
Some dev made a custom one which is a really good idea, but the implementation is not perfect.
After a while, the crosshairs become extremely laggy and so basically useless.
But why cTrader dev Team does not implement such a basic tool? Is it not possible to take the work done and modify it with the skills and experience you have on the platform?
cTrader is not that bad and the idea behind is good, but you are really too slow in developing. Many customers, included me and my friends and colleagues, are trying the platform but it is becoming frustrating...
Thank you.
Replies
dynamites
12 Dec 2019, 14:27
RE:
PanagiotisCharalampous said:
Hi dynamites,
Can you share the link to the indicator?
Best Regards,
Panagiotis
@dynamites
bru34
13 Jun 2020, 17:11
Fixed It in part
Here is the fix Bro.
New Code, i put it in comments.
*****************************************
using System;
using cAlgo.API;
using cAlgo.API.Internals;
using cAlgo.API.Indicators;
using cAlgo.Indicators;
using System.Collections.Generic;
using System.Threading;
namespace cAlgo
{
[Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)]
public class CrossHairSync : Indicator
{
[Parameter("LineStyle", Group = "Style for Current Chart", DefaultValue = LineStyle.Solid)]
public LineStyle LS { get; set; }
[Parameter("Thickness", Group = "Style for Current Chart", DefaultValue = 1)]
public int Thc { get; set; }
[Parameter("Color", Group = "Style for Current Chart", DefaultValue = "White")]
public string Col { get; set; }
[Parameter("Opacity", Group = "Style for Current Chart", DefaultValue = 60)]
public int Opc { get; set; }
private Color Colour;
protected override void Initialize()
{
Opc = (int)(255 * 0.01 * Opc);
Colour = Color.FromArgb(Opc, Color.FromName(Col).R, Color.FromName(Col).G, Color.FromName(Col).B);
Crosshair.AddChart(this);
Chart.MouseMove += OnChartMouseMove;
Chart.MouseLeave += OnChartMouseLeave;
}
void OnChartMouseLeave(ChartMouseEventArgs obj)
{
Crosshair.DeleteCrosshair();
}
void OnChartMouseMove(ChartMouseEventArgs obj)
{
Crosshair.DrawCrosshair(Bars.OpenTimes[(int)obj.BarIndex], obj.YValue, LS, Thc, Colour);
}
public override void Calculate(int index)
{
}
}
public static class Crosshair
{
private static List<Indicator> Indicators = new List<Indicator>();
private static object _lock = new object();
public static void DrawCrosshair(DateTime x, double y, LineStyle ls, int thc, Color colour)
{
try
{
lock (_lock)
{
foreach (Indicator i in Indicators)
{
Thread t = new Thread(() =>
{
if (i.Chart.TopY > y && i.Chart.BottomY < y)
{
i.BeginInvokeOnMainThread(() => { i.Chart.DrawHorizontalLine("HCL", y, colour, thc, ls); });
}
System.DateTime xRight = i.Chart.Bars.LastBar.OpenTime;
if (xRight.CompareTo(x) > 0)
{
i.BeginInvokeOnMainThread(() => { i.Chart.DrawVerticalLine("VCL", x, colour, thc, ls); });
}
});
t.Start();
}
}
} catch (Exception)
{
}
}
public static void DeleteCrosshair()
{
try
{
lock (_lock)
{
foreach (Indicator i in Indicators)
{
Thread t = new Thread(() =>
{
i.BeginInvokeOnMainThread(() => { i.Chart.RemoveObject("HCL"); });
i.BeginInvokeOnMainThread(() => { i.Chart.RemoveObject("VCL"); });
});
t.Start();
}
}
} catch (Exception)
{
}
}
public static void AddChart(Indicator indicator)
{
try
{
lock (_lock)
Indicators.Add(indicator);
} catch (Exception e)
{
indicator.Print(e);
}
}
}
}
@bru34
dynamites
17 Jun 2020, 18:33
Thanks.
Now I have only to understand how to insert the fix!!! (I am not a developer, just a trader...) :-)
@dynamites
PanagiotisCharalampous
12 Dec 2019, 14:24
Hi dynamites,
Can you share the link to the indicator?
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous