Accessing chart objects
Created at 07 Mar 2017, 11:44
Accessing chart objects
07 Mar 2017, 11:44
I would need to find a manually drawn line by name by its comment. Is this currently possible?
ctrader.guru
09 Feb 2024, 06:00
Try this approach
using cAlgo.API; namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.FullAccess)] public class MyRobot : Robot { protected override void OnStart() { ChartTrendLine desiredLine = null; foreach (ChartObject line in Chart.Objects) { if (line.ObjectType == ChartObjectType.TrendLine && line.Comment == "Your Comment") { desiredLine = (ChartTrendLine)line; break; } } // Access the desired line if (desiredLine != null) { // Do something with the desired line Print("Desired line value: " + desiredLine.Name); } else { Print("No line with the specified comment found."); } } } }
@ctrader.guru