Easy way to remove chart lines/text in code?
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.
Replies
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
PanagiotisCharalampous
01 Nov 2019, 09:04
Hi FireMyst,
There is a RemoveObject function for this.
Best Regards,
Panagiotis
@PanagiotisCharalampous