How to detect indicator on the chart?

Jun 11, 2020
Hello experienced coders, I'm new in MQL and I need some guidance.

The thing is I'm making a line of on-chart buttons that will launch specific indicators, functions etc.
So far so good the button loads an indicator 'X' when pressed and deletes it when the button is unpressed, but I would like to add another function that will detect indicator 'X' on chart an automatically set the button to pressed state in case I will drag and drop the 'X' indicator from indicator list.
I was trying to do that using ChartIndicatorsTotal() and ChartIndicatorName()" but no luck, probably I messed up something.
Can someone please show me the proper way how to do it?

Thank you.