Download MetaTrader 5

Prevent EA running on MetaTrader start

To add comments, please log in or register
spikedog
35
spikedog  

If I have a running EA and shut down MetaTrader when I restart MetaTrader the EA begins running again automatically. I can see why this would be normal behaviour but in case market conditions have changed since closing MetaTrader I want to block the automatic start and have a chance to decide to run the EA after restarting MetaTrader.

Is there a way to code my EA so that it does not run on MetaTrader start and waits for some operator action?

SpikeDog

whroeder1
16058
whroeder1  
  1. If conditions have changed, shouldn't the EA already recompute and adjust. Fix the code.
  2. Not compiled, not tested
    bool isDisabled = false;
    int init(){
       int ret = MessageBox("Press Return to begin autotrading", WindowExpertName(), MB_OKCANCEL+MB_ICONQUESTION);
       isDisabled = (ret == IDCANCEL);
    }
    int start(){ if(isDisabled) return;
    Not compiled, not tested
spikedog
35
spikedog  
WHRoeder:
  1. If conditions have changed, shouldn't the EA already recompute and adjust. Fix the code.
  2. Not compiled, not tested Not compiled, not tested


Thanks WHRoeded.

The problem with option 1 is that conditions set by operator input can change. The inputs are set in the EA dialog but when MetaTrader first starts the EA just begins running with the last set of input it had. The friend using this EA doesn't think to shut down the EA before closing MT for the day.

Your option 2 is a good solution though. Simple and elegant. Thanks for that.

To add comments, please log in or register