Easy way to remove chart lines/text in code?

Created at 01 Nov 2019, 08:53
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!
FI

firemyst

Joined 26.03.2019

Easy way to remove chart lines/text in code?
01 Nov 2019, 08:53


HI all:

I have code where I draw text/lines on a chart within a cbot as follows:

Chart.DrawHorizontalLine(key + " line", priceWherePositionCanBeOpened, Color.Goldenrod, 2, LineStyle.DotsRare);

Chart.DrawText(key + " text", "Line Where Position Will Be Opened: "
                + pipsToMoveBeforeEnteringPosition + " pips"
                + " (" + Math.Round(priceWherePositionCanBeOpened, CONST_numberOfDecimalPlacesToRoundToForDebugOutput) + ")",
                _marketSeriesLong.Close.Count - CONST_textOffSetOnLinesDrawn, priceWherePositionCanBeOpened, Color.Goldenrod);

I know there's the "IsAlive" property, but that's only a "get", we can't "set" those values (which would make it sooooooooo easy to remove lines/text we've drawn! Spotware? API feature? :-) )

 

Is there an easy way to delete/remove these later once they're drawn? Or do we have to set the Y-axis parameter to some value which is way off the chart?

Thank you.

 


@firemyst
Replies

PanagiotisCharalampous
01 Nov 2019, 09:04

Hi FireMyst,

There is a RemoveObject function for this.

Best Regards,

Panagiotis


@PanagiotisCharalampous

firemyst
01 Nov 2019, 10:47

RE:

Panagiotis Charalampous said:

Hi FireMyst,

There is a RemoveObject function for this.

Best Regards,

Panagiotis

Awesome!

Thank you @Panagiotis.

For everyone else's FYI, you have to call it like:

Chart.RemoveObject(chartKey);

 


@firemyst