IndicatorRemove

To add comments, please log in or register
Carl Schreiber
Moderator
7247
Carl Schreiber  

Is there a way that an indicator can remove itself?

I tried ExpertRemove() which worked as far as I remember for mql4 - but mql5 it does not - do I have to force a division by zero or an invalid array access?

kypa
1031
kypa  
The pirate way - induce some fatal error. Works with experts, might crash the terminal though.
Francesco Rubeo
2573
Francesco Rubeo  
Carl Schreiber:

Is there a way that an indicator can remove itself?

I tried ExpertRemove() which worked as far as I remember for mql4 - but mql5 it does not - do I have to force a division by zero or an invalid array access?

Maybe you can apply a template with ChartApplyTemplate function and you will not have any indicator on the chart...

kypa
1031
kypa  

There is also a proper way:

https://www.mql5.com/en/docs/standardlibrary/technicalindicators/cindicators/cindicator/cindicatordeletefromchart

Or just ChartIndicatorDelete();

Documentation on MQL5: Standard Library / Indicators / Base classes / CIndicator / DeleteFromChart
Documentation on MQL5: Standard Library / Indicators / Base classes / CIndicator / DeleteFromChart
  • www.mql5.com
Standard Library / Indicators / Base classes / CIndicator / DeleteFromChart - Reference on algorithmic/automated trading language for MetaTrader 5
Carl Schreiber
Moderator
7247
Carl Schreiber  

My indicator doesn't use this library.

So far I use: Print(1.0/(sqrt(1)-1));

kypa
1031
kypa  

This is the built-in function that the function from the library calls:

https://www.mql5.com/en/docs/chart_operations/chartindicatordelete

Documentation on MQL5: Chart Operations / ChartIndicatorDelete
Documentation on MQL5: Chart Operations / ChartIndicatorDelete
  • www.mql5.com
//|                                    Demo_ChartIndicatorDelete.mq5 | //|                        Copyright 2011, MetaQuotes Software Corp. | //|                                              https://www.mql5.com | //| Custom indicator initialization function                         |                           ...
Carl Schreiber
Moderator
7247
Carl Schreiber  

Yep, I just found it.

hmm - similar things should have similar names that would make live easier!

To add comments, please log in or register