UninitializeReason() Question

 

I'm drawing objects on my chart and using the UninitializeReason case REASON_REMOVE.

If I close the MetaTrader platform, the objects are deleted - even though the expert or indicator was left attached to the chart.

Is this a bug or is this normal behaviour? One would think this wouldn't happen.

Thank you.

 
JPS:

I'm drawing objects on my chart and using the UninitializeReason case REASON_REMOVE.

If I close the MetaTrader platform, the objects are deleted - even though the expert or indicator was left attached to the chart.

Is this a bug or is this normal behaviour? One would think this wouldn't happen.

Thank you.

When MT4 is closed down the Indicator is removed from the chart. When MT4 is run the Indicator is reattached to the chart.
 

Interesting. Wish it worked differently. Thanks for clearing this up for me. Much appreciated.

 
JPS:

I'm drawing objects on my chart and using the UninitializeReason case REASON_REMOVE.

If I close the MetaTrader platform, the objects are deleted - even though the expert or indicator was left attached to the chart.

Is this a bug or is this normal behaviour? One would think this wouldn't happen.

Thank you.


Do you mean that you are placing the objects or that the code is creating them?

If you are manually placing objects and they are being deleted, it is probably because your code is deleting all objects in deinit.

If you don't want this to happen, modify the code to delete only objects created by the code.

 
GumRai:


Do you mean that you are placing the objects or that the code is creating them?

If you are manually placing objects and they are being deleted, it is probably because your code is deleting all objects in deinit.

If you don't want this to happen, modify the code to delete only objects created by the code.

I think the OP uses REASON_REMOVE in deinit() to decide to remove Objects or not, he incorrectly assumed that the Indicator stayed on the chart when MT4 was shut down and that the deinit reason would not be REASON_REMOVE in that case . . .
 
RaptorUK:
I think the OP uses REASON_REMOVE in deinit() to decide to remove Objects or not, he incorrectly assumed that the Indicator stayed on the chart when MT4 was shut down and that the deinit reason would not be REASON_REMOVE in that case . . .


It is not actually clear from the OP whether the objects are being drawn by the indicator or added manually.

If drawn, by the indicator, then usually they will be re-drawn when MT4 is re-opened, so not a problem.

Reason: