Use CheckStopLoss_Takeprofit function introduced in this link.

The checks a trading robot must pass before publication in the Market
- www.mql5.com
Before any product is published in the Market, it must undergo compulsory preliminary checks in order to ensure a uniform quality standard. This article considers the most frequent errors made by developers in their technical indicators and trading robots. An also shows how to self-test a product before sending it to the Market.

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
Good day
I have no idea why this issue keeps on happening and am hoping you guys/gals can help me.
I have the following code;
It compiles fine and has no errors when I attach it to the chart window, but when I run it through the strategy tester is keeps on giving me the same error;
2024.03.07 11:44:23.507 Core 01 2024.03.05 23:59:53 Invalid stop loss or take profit levels for sell order.
2024.03.07 11:44:23.507 Core 01 2024.03.05 23:59:54 Invalid stop loss or take profit levels for sell order.
2024.03.07 11:44:23.507 Core 01 2024.03.05 23:59:55 Invalid stop loss or take profit levels for sell order.
2024.03.07 11:44:23.507 Core 01 2024.03.05 23:59:56 Invalid stop loss or take profit levels for sell order.
2024.03.07 11:44:23.507 Core 01 2024.03.05 23:59:57 Invalid stop loss or take profit levels for sell order.
2024.03.07 11:44:23.507 Core 01 2024.03.05 23:59:59 Invalid stop loss or take profit levels for sell order.
2024.03.07 11:44:23.507 Core 01 final balance 10000.00 USD
2024.03.07 11:44:23.507 Core 01 DEX 900 DOWN Index,M1: 429255 ticks, 7200 bars generated. Environment synchronized in 0:00:00.025. Test passed in 0:00:01.003.
2024.03.07 11:44:23.507 Core 01 DEX 900 DOWN Index,M1: total time from login to stop testing 0:00:01.028 (including 0:00:00.025 for history data synchronization)
2024.03.07 11:44:23.507 Core 01 914 Mb memory used including 26 Mb of history data, 64 Mb of tick data
2024.03.07 11:44:23.507 Core 01 log file "C:\Users\Dream Design\AppData\Roaming\MetaQuotes\Tester\FB9A56D617EDDDFE29EE54EBEFFE96C1\Agent-127.0.0.1-3000\logs\20240307.log" written
2024.03.07 11:44:23.883 Core 01 connection closed
Can anyone please help me or tell me what I am doing wrong?
P.S. I am not a programmer. I coded this EA using ChatGPT. It is an experiment.
Thank you.