Accessing chart objects drawn by a custom indicator.

Created at 28 May 2022, 23:55
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
WI

Willie_Dladla

Joined 15.05.2020

Accessing chart objects drawn by a custom indicator.
28 May 2022, 23:55


Hello,

Can someone please assist: How can i access chart objects drawn by custom indicator from bot?

I have a custom indicator that draws blue and red rectangles on the chart. I want to access these rectangles and their coordinates from my bot.

Thank you in advance.


@Willie_Dladla
Replies

firemyst
29 May 2022, 13:55

Not sure if it can be done, but to access a chart object in a bot that's drawn from a bot, you would do something like this example if you're looking for a horizontal line:

ChartHorizontalLine obj = (ChartHorizontalLine)Chart.FindObject("the name you gave the line when you drew it");

 


@firemyst

Willie_Dladla
29 May 2022, 14:37

RE:

firemyst said:

Not sure if it can be done, but to access a chart object in a bot that's drawn from a bot, you would do something like this example if you're looking for a horizontal line:

ChartHorizontalLine obj = (ChartHorizontalLine)Chart.FindObject("the name you gave the line when you drew it");

 

Hello firemyst,

 

Thanks for the response, So what would you suggest? Will it be possible to transfer the indicator's code inside a bot?


@Willie_Dladla

amusleh
30 May 2022, 09:50

RE: RE:

willyvusi04 said:

firemyst said:

Not sure if it can be done, but to access a chart object in a bot that's drawn from a bot, you would do something like this example if you're looking for a horizontal line:

ChartHorizontalLine obj = (ChartHorizontalLine)Chart.FindObject("the name you gave the line when you drew it");

 

Hello firemyst,

 

Thanks for the response, So what would you suggest? Will it be possible to transfer the indicator's code inside a bot?

It's possible, all chart objects are inside Chart.Objects collection.

You can access an object by name, but you have to cast to it's type by using ObjectType property.


@amusleh