Please enable OnDeInit() function on indicator as it can not delete Comment/Object Text on the chart when removed from chart. So we still see its comment and text lefted int the chart but the indicator have been removed.
See code below:
If I added the ObjectDelete(chart_id,name) in the end of my code at OnCalculate() the text shown in the chart will become flicker and even disappear while no new incoming tick.
By the way, this code not approved yet to published in https://www.mql5.com/en/code.
Thanks in advance.
1. In the future please use SRC button to post the code, it will make the code more colorful than using text style.
2. You really don't have to post the whole code if it's to be published in code base, just show your OnDeinit(). You want me to edit your code again ?
3. I see that you are using Windows 7 (what bit is that ?). Due to UAC issue, we ussualy install MT outside C:\Program Files\..., like for example we install MT in C:\My app\MT5\....
FYI, I'm using Vista, and I have the same code in indicator OnDeinit, and I don't have problem deleting comment and object like your problem.
1. In the future please use SRC button to post the code, it will make the code more colorful than using text style.
2. You really don't have to post the whole code if it's to be published in code base, just show your OnDeinit(). You want me to edit your code again ?
3. I see that you are using Windows 7 (what bit is that ?). Due to UAC issue, we ussualy install MT outside C:\Program Files\..., like for example we install MT in C:\My app\MT5\....
FYI, I'm using Vista, and I have the same code in indicator OnDeinit, and I don't have problem deleting comment and object like your problem.
1. Thank you. I was use SRC to paste my code but not sure how it works so next time will more careful when using this feature.
2. Nope. Won't do it anymore.
3. I'm using Windows 7 64 bit. By default mt5 installer instal mt5 folders at C:\Program Files\... rather than at C:\Program Files(x86)\.... as did by mt4 installer.
I am not sure why it work at Vista but not at Windows 7,.. so kindly please check
1. Thank you. I was use SRC to paste my code but not sure how it works so next time will more careful when using this feature.
2. Nope. Won't do it anymore.
3. I'm using Windows 7 64 bit. By default mt5 installer instal mt5 folders at C:\Program Files\... rather than at C:\Program Files(x86)\.... as did by mt4 installer.
I am not sure why it work at Vista but not at Windows 7,.. so kindly please check
1. Are you sure you don't me to edit your code to show just the OnDeinit part ?
2. I installed my MT5 (and MT4) outside C:\Program Files\..., in C:\Other Program Files\...
1. Are you sure you don't me to edit your code to show just the OnDeinit part ?
2. I installed my MT5 (and MT4) outside C:\Program Files\..., in C:\Other Program Files\...
1. Well, please edit my code :D
2. I'm not sure i just using their default destination folder when install them to avoid mistaken in the installation process
1. Well, please edit my code :D
2. I'm not sure i just using their default destination folder when install them to avoid mistaken in the installation process
Code edited :D.
Well, latest MT5 is build 772, not 770, so you may want to upgrade first and try again.
Anyway, tell you what, why don't you just try to install outside default directory. However, if you worry that installing outside default directory may ruin your PC, then use your PC System Restore. Here's how you should do it.
1. Run System File Checker (SFC) (click that) to fix any system file that may corrupt. After running SFC you must restart and in some case you must shutdown after that restart. Run SFC until it finish 100%, if not finish 100 %, you have to run SFC in Safe Mode.
Here's the command for command prompt to run SFC and restart PC in 2 seconds after SFC finish.
sfc /scannow & shutdown /r /t 2
You may also want to run sfc /? to find out what SFC is, before running an SFC. BTW, I run SFC on weekly basis before running Disk CleanUp and Defrag.
2. After running SFC, run your System Restore and create new System Restore, just follow instruction over there.
3. Install MT5 outside C:\Program Files\... .After installation complete, you may want to copy historical data from old MT5 to the new one, so you don't have to download historical data again.
4. After trying with your new MT5 and later if you think you're not comfortable with this, run System Restore and restore back your PC to a time before installing MT5.
- support.microsoft.com
Code edited :D.
Well, latest MT5 is build 772, not 770, so you may want to upgrade first and try again.
Anyway, tell you what, why don't you just try to install outside default directory. However, if you worry that installing outside default directory may ruin your PC, then use your PC System Restore. Here's how you should do it.
1. Run System File Checker (SFC) (click that) to fix any system file that may corrupt. After running SFC you must restart and in some case you must shutdown after that restart. Run SFC until it finish 100%, if not finish 100 %, you have to run SFC in Safe Mode.
Here's the command for command prompt to run SFC and restart PC in 2 seconds after SFC finish.
sfc /scannow & shutdown /r /t 2
You may also want to run sfc /? to find out what SFC is, before running an SFC. BTW, I run SFC on weekly basis before running Disk CleanUp and Defrag.
2. After running SFC, run your System Restore and create new System Restore, just follow instruction over there.
3. Install MT5 outside C:\Program Files\... .After installation complete, you may want to copy historical data from old MT5 to the new one, so you don't have to download historical data again.
4. After trying with your new MT5 and later if you think you're not comfortable with this, run System Restore and restore back your PC to a time before installing MT5.
Great. Thank you.
sfc done too.
I see that your code is published. Congrats.
Sorry to say that I forgot to tell that deinit usually written like this
void OnDeinit(const int reason) { //--- code goes here }
variable reason is for UninitializationReason.
I see that your code is published. Congrats.
Sorry to say that I forgot to tell that deinit usually written like this
variable reason is for UninitializationReason.
Great, after an update this issue is resolved. Now the code help came out when i type name of the function (OnDeInit()) that not shown before and it works. I just sent an update for my code for moderator's check. It should be published in nearest future.
In previous version (before updates) the function of OnDeInit have no color and did not work.
Kindly please close or delete this thread because the issue was resolved very long time ago.
Thank you,

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Please enable OnDeInit() function on indicator as it can not delete Comment/Object Text on the chart when removed from chart. So we still see its comment and text lefted int the chart but the indicator have been removed.
See code below:
If I added the ObjectDelete(chart_id,name) in the end of my code at OnCalculate() the text shown in the chart will become flicker and even disappear while no new incoming tick.
By the way, this code not approved yet to published in https://www.mql5.com/en/code.
Thanks in advance.
tomsuk001