Sorting objects (horizonal lines) by price value
Sorting objects (horizonal lines) by price value
08 Jul 2020, 12:08
I need to sort the chart object by their price value (y1) when there is more than 2 so i can make changes to the highest object, what's the best way to do this?.
I've already got the function to change the line, just need a way to get it.
I'm using this repository
foreach (var signalLine in SignalLineRepository.GetLines())
{
}
Replies
Ketu
08 Jul 2020, 12:17
RE:
PanagiotisCharalampous said:
Hi Ketu,
You need to post the complete code for us to be able to help you.
Best Regards,
Panagiotis
It's based on your LinesTrader sample
public ProtoSignalLine(Chart chart, SignalType? signalType, DateTime time1, double y1)
{
_chart = chart;
_signalType = signalType;
double y2 = y1;
DateTime time2 = time1.AddHours(20);
_line = _chart.DrawTrendLine(string.Format("1", Guid.NewGuid()), time1, y1, time2, y2, LineColor);
_line.ExtendToInfinity = false;
_line.Thickness = 1;
_line.IsInteractive = true;
}
@Ketu
PanagiotisCharalampous
08 Jul 2020, 12:30
Hi Ketu,
Change
private readonly ChartTrendLine _chartTrendLine;
to
public ChartTrendLine ChartTrendLine { get; }
and then order the collection accordingly as below
foreach (var signalLine in SignalLineRepository.GetLines().OrderByDescending(x => x.ChartTrendLine.Y1))
Best Regards,
Panagiotis
@PanagiotisCharalampous
PanagiotisCharalampous
08 Jul 2020, 12:11
Hi Ketu,
You need to post the complete code for us to be able to help you.
Best Regards,
Panagiotis
Join us on Telegram
@PanagiotisCharalampous