Custom Indicator draws a ChartHorizontalLine. How do access this object in a Robot?
Custom Indicator draws a ChartHorizontalLine. How do access this object in a Robot?
07 Nov 2023, 10:04
I have an Indicator that draws a ChartHorizontalLine. Here's a simplified example:
using cAlgo.API;
namespace cAlgo.Indicators
{
[Indicator(IsOverlay = true, AccessRights = AccessRights.None)]
public class MyIndicator : Indicator
{
public ChartHorizontalLine? MyHorizontalLine { get; set; }
// ...
public override void Calculate(int index)
{
MyHorizontalLine = Chart.DrawHorizontalLine("MyHorizontalLine", Ask - Symbol.PipSize * 10, Color.Green);
}
// ...
}I also have a Robot that tries to look for the chart objects, e.g.:
using cAlgo.API;
namespace cAlgo.Robots
{
[Robot(AccessRights = AccessRights.None)]
public class MyRobot : Robot
{
// ...
protected override void OnTick()
{
Print("Chart.Objects.Count: ", Chart.Objects.Count);
if (Chart.FindObject("MyHorizontalLine") is ChartHorizontalLine MyHorizontalLine)
{
Print("MyHorizontalLine.Y: ", MyHorizontalLine.Y);
}
}
// ...
}
}The line appears on the chart when the Indicator is running but the Robot cannot see the object and prints 0.
Running the print statement in the indicator returns the expected 1.
Is it possible to make the horizontal line from the indicator available as a chart object by name to the Robot?
I don't see the horizontal line as an object in the objects manager, either in the Drawing or Indicators panels.
Replies
PanagiotisCharalampous
08 Nov 2023, 06:30
Hi there,
You need to set your chart object as interactive
Best regards,
Panagiotis
@PanagiotisCharalampous
shanku
08 Nov 2023, 06:41
( Updated at: 08 Nov 2023, 12:53 )
RE: Custom Indicator draws a ChartHorizontalLine. How do access this object in a Robot?
PanagiotisCharalampous said:
Hi there,
You need to set your chart object as interactive
Best regards,
Panagiotis
Thanks Panagiotis! Was just about to look into mapping the values I wanted into a DataSeries but setting .IsInteractive made the line available to the Robot.
I'm happy to sacrifice it being interactive (I would rather it be non-interactive) if it simplifies getting the value.
@shanku

PanagiotisCharalampous
07 Nov 2023, 11:08 ( Updated at: 08 Nov 2023, 12:53 )
Hi there,
Try making the line interactive
Best regards,
Panagiotis
@PanagiotisCharalampous