Please look at code below, I have a time based stop loss function below but it is not working properly as It only looping on on the first time only (TimeBasedSLperiodLoss1), and does not go to TimeBasedSLperiodLoss2. Any help would be highly appreciated.
- Parabolic SAR - Trend Indicators - Indicators - Charts - MetaTrader 5 for Android
- Parabolic SAR - Trend Indicators - Indicators - Chart - MetaTrader 5 for iPhone
- Help - Main menu
and does not go to TimeBasedSLperiodLoss2
When it must go tp period2?
Can you please fix the above bug?
Make these variables static or declare globally.
static bool alreadyExecuted1 = false; static bool alreadyExecuted2 = false; static bool alreadyExecuted3 = false; static bool alreadyExecuted4 = false;Also, use integers when working with time.
extern int TimeBasedSLperiodLoss1 = 300; // in seconds extern int TimeBasedSLperiodLoss2 = 600; extern int TimeBasedSLperiodLoss3 = 900; extern int TimeBasedSLperiodLoss4 = 1200; int TimeBasedSL=0;
Thanks, but the above did not fix the bug. :(
![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