![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Just starting to code in MQL5, I tried to make very simple martingale EA which will double the lot size if we lose and stop after we win. When I tested this on strategy tester, its always written failed instant buy if I input Buy in the position input variable ( extern variable ), but it works if I choose sell. and its weird if I change the code in line 108, 109..
From..
takeProfit = NormalizeDouble( tick.ask + _takeProfit * Point() * 10, _Digits ) ;
stopLoss = NormalizeDouble( tick.ask - _stopLoss * Point() * 10, _Digits ) ;
To:
takeProfit = NormalizeDouble( tick.bid+ _takeProfit * Point() * 10, _Digits ) ;
stopLoss = NormalizeDouble( tick.bid- _stopLoss * Point() * 10, _Digits ) ;
It'll work although it seems not connected.
Here's the code: