Mini-review – We asked ChatGPT!
In the previous article, I think you can see that if you can guide ChatGPT well, you can write MQL5 programs. This time, on the contrary, I would like to see “the response when the code without the problem is presented".
What I presented was a self-made MQL4 tool, similar to the “one-click trade" that comes with MetaTrader, where orders are placed when you click a button. However, when I clicked on it, it sometimes didn’t place an order, and there was a phenomenon that I couldn’t order continuously.
Therefore, I asked the following questions.
Q: In the program below, the button is clicked, but the order is not placed. There are no errors in your comment.
(Hereafter, all source code is described)
A: Response by ChatGPT: https://chat.openai.com/auth/login
It took me a long time to react, as I was quite lost in thought.
After reviewing your code, I didn’t find any obvious problems that would prevent you from placing orders.
However, the following issues are possible:
- Broker Restrictions: Your broker may not allow certain trades. For example, some brokers may limit trading during certain hours (usually when the market is closed). This depends on the time of day you are trying to trade.
- Market Liquidity: If the liquidity of a particular currency pair is low, orders may take longer to be executed. If you are trading currency pairs with low liquidity, you may encounter this problem.
- Trading allowed: IsTradeAllowed() function may return false. This indicates that MT4 is unable to accept new orders. This problem can occur during times when trading is not allowed.
- Slips: Slips (inability to trade at the best price) can prevent order execution. Especially if the market is highly volatile, this problem is likely to occur.
To address these factors, you can try the following:
- Please check with your broker. They should be able to provide details about trading hours and allowed trading.
- Please pay attention to the market hours. In particular, avoid submitting orders when the market is closed.
- Take slip into account. You may want to try increasing the slip value passed to the OrderSend function.
Alternatively, if the OrderSend function fails, you can identify the specific problem by using the GetLastError function to get the error code. Examining this error code can help identify the cause of the problem.
That’s an accurate answer. I haven’t confirmed it, but I’m guessing that the broker I tested is restricting continuous orders using EA.
In addition, the above is a test result of a self-made tool (EA) of MT4 and a demo account of a certain broker. It is not the result at NOZAX, an MT5 broker.
MQL5 Free EA – NOZAX Portfolio No.2
NOZAX Portfolio NO.2
- Account: NZX Zero (ECN) (NOZAX)
- Initial balance: 100,000 yen
- Working EA:
- TraderMind EA MT5: Currency Pair: USDCAD#, Timeframe: 1 Hour, Lot quantity: 0.04 Lot
- White Bear DT for NOZAX v1.13: Currency pair: USDJPY#, Timeframe: 5-minute, Lot quantity: 0.02 lot
- Catastrofix EA MT5: Currency Pair: EURGBP#, EURAUD#, EURNZD#, EURUSD#, GBPCAD#, AUDJPY#, Timeframe: 1 Hour, Lot quantity: 0.01 lot
Results from 22 to 26 May (NOZAX Portfolio No.2)
- TraderMind EA MT5: 0 win and 1 loss, total profit and loss was -2,179 yen (-52.7pips).
- White Bear DT USDJPY: 5 wins and 1 losse, total profit and loss was 1,192 yen (63.2 pips).
- Catastrofix EA MT5: 2 wins and 4 losses, total profit and loss was 1,221 yen (38.2 pips).
Past Results (NOZAX Portfolio No.2）
The individual results of each EA in the portfolio No. 2 are as follows.
- 10 April-26 May 2023
(Trades with a profit of even 1 yen are counted as “winning", while the reverse is counted as “negative")
- Balance: 100,000 yen → 100,721 yen
Portfolio status and plans
This week, TraderMind EA MT5’s 1 loss impacted, resulting in a slight decrease in balance. Next week, I would like to expect that all EAs will step together and increase the balance.