How to get the horizontalLine's Y value?
How to get the horizontalLine's Y value?
09 May 2023, 21:21
I want to get the Y value when i put a horizontalLine on a chart manually.
I tried the following things in the indicator:
protected override void Initialize()
{
Chart.ObjectsAdded += Chart_ObjectsAdded;
}
private void Chart_ObjectsAdded(ChartObjectsAddedEventArgs obj)
{
Print("{0} objects added to chart", obj.ChartObjects.Count);
var objtype = obj.ChartObjects.GetType();
var newobj= obj.ChartObjects;
Print(newobj.Last().Name); // horizontalLine number
Print(newobj.Last().ToString()); // cTrader.Automate.Adapters.ChartApi.ChartObjects.ChartHorizontalLineAdapter
Print(newobj.Last().Comment);
Print(newobj.Last().GetType()); // cTrader.Automate.Adapters.ChartApi.ChartObjects.ChartHorizontalLineAdapter
}
Then, i get the correct name and Comment(nothing),but can't get the Y value.
How to access the chart objects's value like lines(horizontalLine's Y, vertical line's datetime) or rectangle(time and Y)?
Need help, thanks.
Replies
963168364
12 May 2023, 02:37
RE: Thank you so much! It works fine!
PanagiotisChar said:
Hi there,
Here you go
protected override void Initialize() { Chart.ObjectsAdded += Chart_ObjectsAdded; } private void Chart_ObjectsAdded(ChartObjectsAddedEventArgs obj) { if (obj.ChartObjects[0] is ChartHorizontalLine) { Print((obj.ChartObjects[0] as ChartHorizontalLine).Y); } }
Need help? Join us on Telegram
Need premium support? Trade with us
@963168364
PanagiotisChar
10 May 2023, 08:29
Hi there,
Here you go
Aieden Technologies
Need help? Join us on Telegram
Need premium support? Trade with us
@PanagiotisChar