How to reset an EA extern variable to its default setting within the EA

 

I have an EA that i will like to reset its external variables to the default setting within the EA after a trade is taken, can you advise on how to achieve that?


Thanks

Iddy
 

The method I use is to not change them in the first place . . . let me explain. If I want to change an extern I use a local copy, for example . . . extern LineColor = Red if I want o change this color instead of using LineColor = Blue; I use

lLineColor = Blue; then I have the option at a later time to do this: lLineColor = LineColor;

Please don't double post !

 

@ RaptorUk

Thanks, i am not sure that will solve my issue. There is a reset button on the EA property window, i am looking for a way to activate it or trigger a similar reset with the EA code.

Thanks

 

If you don't change them, you don't have to reset them. Like Raptor said, use a copy and reset the copy.

extern color lineColor = Red;
:
int init(){ onInit(); ... }
:
color currentLineColor;
OnInit(){ currentLineColor = lineColor; }
:
if (newTrade){ OnInit(); ...

if you modify globals or externals like slippage *= 10; then EACH deinit/init cycle will increase the variable. Every Chart Refresh, change of pair or timeframe, etc.