Variables doesn't loose their value after an restart

 

Hello,

I have an expert advisior which works with the loss-and profit series from the last orders.

I calculated them by

OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)

....

Is there a posibility to restart the EA an with a loss-and profit series with the value "0" without changing the MagicNumber?? How can I do that?

Lots of thanks!

 

Store the profit that has been accumulated so far in a global variable GlobalVariableSet() when the "cycle" or whatever is over (or in deinit() or in init()) and then during the next cycle simply subtract this number from the total profit, this will give you the profit of the current cycle only. This is how I do it in some of my EAs that keep track of the profit.