He wants to add the indicator to the chart.
Yes, I want it to add into chart.
I was thinking of calling MACD to the chart by pressing a key, and remove it by pressing a key via CHARTEVENT_KEYDOWN.
You can make a template with this indicator and call ChartApplyTemplate
what do you mean?
Exactly what he says.
ChartApplyTemplate()
https://www.mql5.com/en/docs/chart_operations/chartapplytemplate

- www.mql5.com
You can make a template with this indicator and call ChartApplyTemplate
Yes, I want it to add into chart.
I was thinking of calling MACD to the chart by pressing a key, and remove it by pressing a key via CHARTEVENT_KEYDOWN.
You need to use WinAPI call, I already posted the code on this forum, but can't find it now as the Search Engine is not working once again.
https://docs.mql4.com/chart_operations
Is there a way to Close a sub window?
I am calling MACD from my indicator, and when I remove the MACD indicator, it will remove my indicator too.
I need my indicator to be running, just remove the MACD indicator or remove the sub window

How do I draw MACD in the sub windows from code (MQL4)?
I know I can remove the indicator by calling ChartIndicatorDelete.
But how do I call it from code?