![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
let the developers sort it out. here's a screenshot of 3 runs of this script.
It's not working for me.
Bug - it used to work, but now it doesn't.
Thank you for your message.
We'll keep looking.
Found a small bug in PrintCheckResult method (Trade.mqh file, Trade classes, CTrade class).
void CTrade::PrintCheckResult(void) const
{
printf("CheckResult");
// printf("%d,%f,%f,%f,%f,%f,%f,'%s'", - the last but one parameter is unnecessary
printf("%d,%f,%f,%f,%f,%f,'%s'",
m_check_result.retcode,m_check_result.balance,m_check_result.equity,
m_check_result.margin,m_check_result.margin_free,m_check_result.margin_level,
m_check_result.comment);
}
Instead of string: printf("%d,%f,%f,%f,%f,%f,%f,'%s'", - commented out by me
there should be a line: printf("%d,%f,%f,%f,%f,%f,%f,'%s'",
I checked, the corrected function works correctly.
Bug - it used to work, but now it doesn't.
Thanks for the message. Will be available in the next update. To make it work in the current version, use explicit casting for constant or multiplication in general
{
// вот так работает
Print(TimeCurrent()+2*PeriodSeconds(PERIOD_D1));
// а вот так нет (а раньше работало)
datetime time_end=0;
time_end=TimeCurrent()+(long) 2*PeriodSeconds(PERIOD_D1);
Print(time_end);
}
Found a small bug in PrintCheckResult method (Trade.mqh file, Trade classes, CTrade class).
Thank you for the message.
It will be soon fixed.
Thank you for your message. Will be available in the next update. To make it work in the current version use explicit casting for constant or multiplication in general
Thank you. If I understood correctly it was due to type conversion. It's a pity there's no such message at compile time, it would be easier to find
ENUM_TRADE_RETURN_CODES errors must be interpreted correctly in order to handle them correctly. Is there any material to describe them in detail?
In particular, the following errors are not completely understood:
10008
TRADE_RETCODE_PLACED
Order placed
10021
TRADE_RETCODE_PRICE_OFF
No quotes available to process the request
10028
TRADE_RETCODE_LOCKED
Query blocked for processing
10029
TRADE_RETCODE_FROZEN
Order or position frozen
Can someone help with this issue?
ENUM_TRADE_RETURN_CODES errors must be interpreted correctly in order to handle them correctly. Is there any material to describe them in detail?
In particular, the following errors are not completely understood:
10008
TRADE_RETCODE_PLACED
Order placed
10021
TRADE_RETCODE_PRICE_OFF
No quotes available to process the request
10028
TRADE_RETCODE_LOCKED
Query blocked for processing
10029
TRADE_RETCODE_FROZEN
Order or position frozen
Can someone help with this issue?
All of the above refers to the codes which are returned by the server in response to the terminal's request. That's why everything is given in section "Trade server return codes".
It would be logical to assume that the list contains more than just errors.
Now in order.
As for
10008
TRADE_RETCODE_PLACED
Order placed
It would be logical to suppose that this answer is not an error but simply informs the client (the trading terminal) that the order has been successfully placed.
In this case there are three possible solutions:
1. Not to process the answer at all;
2. process the order placement in the OnTrade() block - quite acceptable, but not very correct in my opinion;
In my opinion, this is the best way to process a mechanical trade.
PS
I prefer to process server's responses at the order place and catch the result of actions of a trader, server or other Expert Advisors in OnTrade().
For example, in OnTrade you can catch trader's trade operations (placing or deleting an order, or working with positions).
With respect to
10029
TRADE_RETCODE_FROZEN
Order or position is frozen
There is a certain level at which a position or an order are "frozen" (any operations with them are prohibited).
This level is a distance to the current price at which the server prohibits any actions with the order or position. This distance is measured in pips and is set for each symbol.
It can be obtained using SymbolInfoInteger() withparameter SYMBOL_TRADE_FREEZE_LEVEL.
If you get such a response from the server, you should wait for one of two things to happen:
1. The price has not moved the required distance (larger than that specified in the symbol properties);
2. the order or position does not work under the conditions set in them.
With respect to
10021
TRADE_RETCODE_PRICE_OFF
No quotes to process the request
Probably, when getting this answer, you should check the symbol name (just in case), make sure that the symbol is selected (important for tester and multicasts), check the availability of history, including on the server (if it needs to be downloaded), probably make sure that the market is open and trading on the symbol is possible.
PS
Although here it will be necessary to specify at developers
What about
10028
TRADE_RETCODE_LOCKED
Request blocked for processing
This is probably the most specific of the server's responses listed above... it's more likely to need clarification from the developers (I'll just assume that you should probably just wait for a certain amount of time)...
Regarding
10029
TRADE_RETCODE_FROZEN
Order or position frozen
There is a certain level below which a position or an order are "frozen" (any actions with them are forbidden).
This level is a distance to the current price at which the server prohibits any actions with the order or position. This distance is measured in pips and is set for each symbol.
It can be obtained using SymbolInfoInteger() withparameter SYMBOL_TRADE_FREEZE_LEVEL.
If you get such a response from the server, you should wait for one of two things to happen:
1. The price has not moved the required distance (larger than that specified in the symbol properties);
2. the order or position has not fulfilled the conditions set in them.
Thank you for the detailed answer. I understand the code "10029: TRADE_RETCODE_FROZEN: Order or position is frozen".
However, we still have questions regarding the rest of them (I want to know the exact answer and not just guesses):
10008
TRADE_RETCODE_PLACED
Order placed
10021
TRADE_RETCODE_PRICE_OFF
No quotes available to process the request
10028
TRADE_RETCODE_LOCKED
The request is blocked for processing
In particular, it is not quite clear what "10008: Order has been placed" means, because when the order is queued on the server, a ticket is assigned to it and the code "10009: TRADE_RETCODE_DONE: Request executed" is returned.