So I have created a cap hedge EA (mq4). I ran it on backtest and it worked perfect the first time than I made some extra changes for limit loss, max lot etc...
Then I got some well performing parameters(using optimisation) and decided to put it live on small account with microlots. I was backtesting it on forex but I decided I rather set it to work with Nasdaq. So It started with two positions buy and sell stop it opened correctly eveything. After the first order got activated it didn't closed the other stop order to replace it and went on. So I checked once again and same version and again backtest fine. Code was error and warning free.
So I found that I declared a variable as global without setting it a value. I had somewhere in the code to check and backtest as default got it as false but the live performance wasn't taking it in consideration at all.
I wouldn't call it a bug or something rather my error but seemed interesting so I decided to share with you
a Boolean returns false if not initialized.
Uninitialized variables are random in MT5 and MT4 with strict.
Initialization of Variables
Any variable can be initialized during definition. If a variable is not initialized explicitly, the value stored in this variable can be any. Implicit initialization is not used.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
So I have created a cap hedge EA (mq4). I ran it on backtest and it worked perfect the first time than I made some extra changes for limit loss, max lot etc...
Then I got some well performing parameters(using optimisation) and decided to put it live on small account with microlots. I was backtesting it on forex but I decided I rather set it to work with Nasdaq. So It started with two positions buy and sell stop it opened correctly eveything. After the first order got activated it didn't closed the other stop order to replace it and went on. So I checked once again and same version and again backtest fine. Code was error and warning free.
So I found that I declared a variable as global without setting it a value. I had somewhere in the code to check and backtest as default got it as false but the live performance wasn't taking it in consideration at all.
I wouldn't call it a bug or something rather my error but seemed interesting so I decided to share with you