Download MetaTrader 5
To add comments, please log in or register
Do you need a programmer? Make an order to let the developer find you!
Totom Sukopratomo
23630
Totom Sukopratomo 2013.02.21 14:06 

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:

//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int OnDeInit()
  {
   Comment("");
   ObjectDelete(0,"time");
//---
   return(0);
  }

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

MQL5 Code Base
MQL5 Code Base
  • www.mql5.com
MQL5 Source Code Library for the MetaTrader 5
phi nuts
2185
phi nuts 2013.02.21 14:36  
tomsuk001:

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

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. 

Totom Sukopratomo
23630
Totom Sukopratomo 2013.02.21 14:53  
phi.nuts:

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

phi nuts
2185
phi nuts 2013.02.21 14:58  
tomsuk001:

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\... 

Totom Sukopratomo
23630
Totom Sukopratomo 2013.02.21 15:19  
phi.nuts:

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

phi nuts
2185
phi nuts 2013.02.21 23:55  
tomsuk001:

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.   

Use the System File Checker tool to repair missing or corrupted system files
  • support.microsoft.com
System File Checker is a utility in Windows that allows users to scan for corruptions in Windows system files and restore corrupted files. This article describes how to to scan your system files and to repair missing or corrupted system files in Windows 8.1, Windows 8, Windows 7 or Windows Vista. If a Windows Resource Protection (WRP) file is...
Totom Sukopratomo
23630
Totom Sukopratomo 2013.02.22 05:01  
phi.nuts:

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.

phi nuts
2185
phi nuts 2013.02.26 03:03  

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.

Totom Sukopratomo
23630
Totom Sukopratomo 2013.02.26 13:47  

phi.nuts:

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.


Totom Sukopratomo
23630
Totom Sukopratomo 2015.04.02 20:00  

Kindly please close or delete this thread because the issue was resolved very long time ago.

 

Thank you, 

Khurram Mustafa
21547
Khurram Mustafa 2015.11.15 10:48  
Thank you so much for helping me too. actually I got a same problem but by read your comments or helping words i also resolve my issue .. thanking you all brother :)
/
To add comments, please log in or register