![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
Hello,
I'm currently developing a system that initiates trades in the last 5-minute candle of every Monday. Ideally, most of these trades should hit the SL at the opening of the next day if there's been a bearish gap, as the SL is set at the lowest point of the current day.
Upon backtesting, I observed exceptionally positive results initially. However, after a closer examination of the chart, I identified an issue:
The SL is being triggered at the initially set price, disregarding trading hours and any gaps. The red circles indicate where the position should be closed, but instead, they are being closed at the level of the SL (yellow line).
There's no much code I can show here, I just place a:
trade.Sell(size, asset, bid, sl, 0, comment)
During backtesting, I used the "Open prices only" modeling. Switching to "Every tick" resolves the issue, but it significantly increases backtest and optimization times, especially with 10 years of data.
One potential workaround is to eliminate the SL and monitor the opening price of each day to adjust positions accordingly. However, this solution feels messy, and I'd prefer to explore other options before commiting to it.
Any insights or suggestions would be greatly appreciated, thanks!