Confusion handling ChartObjects

Created at 02 Dec 2023, 00:12
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!
CT

ctid4921325

Joined 18.11.2023

Confusion handling ChartObjects
02 Dec 2023, 00:12


Hi there

Can someone help clarify for me:

Should this line return null if the horizontal line  named “Insight” can't be found and set the value of insightLine to null?:


insightLine = Chart.FindObject("Insight") as ChartHorizontalLine;

If i do:
 

  insightLine = Chart.DrawHorizontalLine("Insight", _linePrice, Color.Red);
  Chart.RemoveObject("Insight");

 

Should I expect that  insightLine.IsAlive should now be False? (but insightLine is ≠ null)

If I do:

  insightLine = Chart.DrawHorizontalLine("Insight", _linePrice, Color.Red);
  Chart.RemoveObject("Insight");
  insightLine = Chart.FindObject("Insight") as ChartHorizontalLine;

 

insightLine should now be null?

 

What I get is, that remove object doesn't seem to change the IsAlive property to false, and once it exists FindObject never seems to return a null, mostly as established with DrawStaticText, but I thought I should clarify whats actually expected behaviour.

 

THanks

 

Glenn


@ctid4921325
Replies

firemyst
11 Dec 2023, 11:27 ( Updated at: 12 Dec 2023, 06:31 )

Duplicate

https://ctrader.com/forum/calgo-support/42431

 


@firemyst