Apply the following to your code. Even though it is for Market products, these checks should also be applied to personal EAs too ...
The checks a trading robot must pass before publication in the Market
MetaQuotes, 2016.08.01 09:30
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.
I have a robot in MQL5 that I use to trade assets on the Brazilian stock exchange. The robot works perfectly for opening buy and sell orders, but when testing it with BTCUSD, it fails on the sell orders. Looking at the logs in the Experts tab, it seems that the values are correct, and I don't understand why it's not working. I'm trading on a demo account with Deriv, using a M1 time frame.
Below are excerpts from the code that I consider important to demonstrate the functioning of the buy and sell functions, followed by a part of the log showing the error in the Experts tab.
Tab Experts log:
2023.05.21 12:12:14.056 SAR (BTCUSD,M1) >>>>>> SELL - lotSize: 0.01 _Symbol: BTCUSD PRC: 26921.0, STL: 26951.0, TKP: 26821.0
2023.05.21 12:12:14.056 SAR (BTCUSD,M1) CTrade::OrderSend: market sell 0.01 BTCUSD sl: 26951.000 tp: 26821.000 [invalid stops]
2023.05.21 12:12:14.056 SAR (BTCUSD,M1) Ordem de Venda - com falha. ResultRetcode: 10016, RetcodeDescription: invalid stops
Can anyone tell me what could be wrong? Could it be the price normalization section?
The error that appears indicates that your SL value is too small.
You can try to give SL a bigger value, then see the results.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have a robot in MQL5 that I use to trade assets on the Brazilian stock exchange. The robot works perfectly for opening buy and sell orders, but when testing it with BTCUSD, it fails on the sell orders. Looking at the logs in the Experts tab, it seems that the values are correct, and I don't understand why it's not working. I'm trading on a demo account with Deriv, using a M1 time frame.
Below are excerpts from the code that I consider important to demonstrate the functioning of the buy and sell functions, followed by a part of the log showing the error in the Experts tab.
Tab Experts log:
2023.05.21 12:12:14.056 SAR (BTCUSD,M1) >>>>>> SELL - lotSize: 0.01 _Symbol: BTCUSD PRC: 26921.0, STL: 26951.0, TKP: 26821.0
2023.05.21 12:12:14.056 SAR (BTCUSD,M1) CTrade::OrderSend: market sell 0.01 BTCUSD sl: 26951.000 tp: 26821.000 [invalid stops]
2023.05.21 12:12:14.056 SAR (BTCUSD,M1) Ordem de Venda - com falha. ResultRetcode: 10016, RetcodeDescription: invalid stops
Can anyone tell me what could be wrong? Could it be the price normalization section?