REASON_CHARTCHANGE --> OnInit()

 

Hi,

is there a way to pass the reason for deinitializiation to the new initialization process?

The only way I can think of is using global terminal variables.


Sven

 
svengralla:

Hi,

is there a way to pass the reason for deinitializiation to the new initialization process?

The only way I can think of is using global terminal variables.


Sven

Hi svengralla, there are several ways. Another way could be an IO file or a Log file, for instance.

 
figurelli:

Hi svengralla, there are several ways. Another way could be an IO file or a Log file, for instance.


Ok, thank you.

 
svengralla:

Hi,

is there a way to pass the reason for deinitializiation to the new initialization process?

The only way I can think of is using global terminal variables.


Sven

You don´t need to pass it because the terminal has stored it at deinit.

In the OnInit() function you just analyze the reason.

switch(UninitializeReason())
     {
      case REASON_CHARTCLOSE:   break;
      case REASON_REMOVE:  break;
      case REASON_RECOMPILE:  break;
      case REASON_CHARTCHANGE: break;
      case REASON_PARAMETERS:  break;
      case REASON_ACCOUNT: break; 
     }
 
fxtr51:

You don´t need to pass it because the terminal has stored it at deinit.

In the OnInit() function you just analyze the reason.

switch(UninitializeReason())
     {
      case REASON_CHARTCLOSE:   break;
      case REASON_REMOVE:  break;
      case REASON_RECOMPILE:  break;
      case REASON_CHARTCHANGE: break;
      case REASON_PARAMETERS:  break;
      case REASON_ACCOUNT: break; 
     }

Hello,

Please use the SRC button when you post code. Thank you.


About your solution, this doesn't work in all cases. For example if the chart is closed, so your EA is completely removed from memory, and you don't receive this value with UninitializeReason().

 
angevoyageur:

About your solution, this doesn't work in all cases. For example if the chart is closed, so your EA is completely removed from memory, and you don't receive this value with UninitializeReason().

Yes, I see.

In my case the chart is not closed, but if we have to take that possibility into account, it is necessary to save the value in a file.

Thanks for clarifying it.

Reason: