FORTS: To help beginners - page 4

 
Sergey Chalyshev:
What does this have to do with the ava? He can't write on the forum, he's permanently banned.
OK, I didn't know there was a "partial" ban. That's a shame.
 
Sergey Chalyshev:
What's that got to do with the ava? He can't write on the forum, he's banned forever.

No, he's been unbanished.

The banned users are written in crossed out.

 
Andrey Khatimlianskii:

No, he's been unbanished.

Banned users are written in crossed out.

I thought so too, you'd better ask the moderators, they know for sure.
 
Mikhail Filimonov:

Features:

Receiving confirmation (TRADE_RETCODE_PLACED ) in OrderSend() return code and order ticket,

and for the OrderSendAsync() function in OnTradeTransaction(), this does not at all mean that

the order is really EXPOSED to an exchange.

So an additional check of the order status is needed (just as for other actions on the order).

if ( OrderSend( request, result ) )
{
  if ( result.retcode == TRADE_RETCODE_PLACED )
  { 
    ticket = result.order;
  }
}

https://www.mql5.com/ru/docs/constants/structures/mqltraderesult

It says that the ticket is filled only when thetrade type isTRADE_ACTION_PENDING.

If the operation is TRADE_ACTION_DEAL, will the order ticket be returned in result.order?

Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура результата торгового запроса
Документация по MQL5: Стандартные константы, перечисления и структуры / Структуры данных / Структура результата торгового запроса
  • www.mql5.com
Стандартные константы, перечисления и структуры / Структуры данных / Структура результата торгового запроса - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Yes.
 
Sergei Vladimirov:
Yes.

When does error 10013 occur in response to OrderCheck()?

Here is the code of my script:

   MqlTradeRequest   m_request;         
   MqlTradeCheckResult m_check_result;  
   
   m_request.action      =TRADE_ACTION_DEAL;
   m_request.symbol      =Symbol();
   m_request.magic       =001;
   m_request.volume      =1.00;
   m_request.type        =ORDER_TYPE_SELL;
   m_request.type_filling=ORDER_FILLING_RETURN;
   if(!OrderCheck(m_request,m_check_result))
      Print(__FUNCTION__+": order check failed.");
   else
      Print(__FUNCTION__+": order check passed.");
   Print(__FUNCTION__+": symbol=",m_request.symbol,", operation=",m_request.type,", volume=",m_request.volume);
   Print(__FUNCTION__+": retcode=",m_check_result.retcode,", balance=",m_check_result.balance,", equity=",m_check_result.equity,", profit=",m_check_result.profit,
            ", margin=",m_check_result.margin,", margin_free=",m_check_result.margin_free,", margin_level=",m_check_result.margin_level,
            ", comment=",m_check_result.comment);

Here's the log I'm getting:

Check (RTS-6.16,M30)    OnStart: retcode=10013, balance=0.0, equity=0.0, profit=2.121995790965272 e-314, margin=0.0, margin_free=0.0, margin_level=0.0, comment=Invalid request
Check (RTS-6.16,M30)    OnStart: symbol=RTS-6.16, operation=1, volume=1.0
Check (RTS-6.16,M30)    OnStart: order check failed.
 
igorbel:

When does error 10013 occur in response to OrderCheck()?

Here is the code of my script:

Here's the log I get:

Passed when added m_request.expiration =0, although the help says:

Exchange Execution.

Trade order to open a position in Exchange Execution mode. Requires 5 fields to be specified:

  • action
  • symbol
  • volume
  • type
  • type_filling

You can also specify magic and comment fields.

 

But the weirdness doesn't end there.

1 lot Buy:

Check (RTS-6.16,M30) OnStart: retcode=0, balance=530863.24, equity=538989.4399999999, profit=2.121995790965272e-314, margin=211242.25, margin_free=319620.99, margin_level=255.1522907941001, comment=Done

Check (RTS-6.16,M30) OnStart: symbol=RTS-6.16, operation=0, volume=1.0

Margin for the transaction 211242.25, the same as the current margin - all correct as the current short position for RTS-6.16 is 2 contracts. Initial margin for 1 contract RTS-6.16 17388.75

I add one more lot.

2 lots Buy:

Check (RTS-6.16,M30) OnStart: retcode=0, balance=651428.4399999999, equity=659212.76, profit=2.121995790965272e-314, margin=211242.25, margin_free=440186.19, margin_level=312.0648260468727, comment=Done

Check (RTS-6.16,M30) OnStart: symbol=RTS-6.16, operation=0, volume=2.0

All ok, as the current position is 2 Sell, the margin remains unchanged.

Now 3 Buy contracts:

2016.04.28 01:26:47.319 Check (RTS-6.16,M30) OnStart: retcode=0, balance=651428.4399999999, equity=658739.4, profit=2.121995790965272e-314, margin=246019.75, margin_free=405408.69, margin_level=267.7587470111648, comment=Done

2016.04.28 01:26:47.319 Check (RTS-6.16,M30) OnStart: symbol=RTS-6.16, operation=0, volume=3.0

Margin value at once 246019.75. How come? For 1 contract only 17k. What about the other values (in the previous cases too)? Where did the equity and balance come from? I don't even have that much in my account. margin_free is also wrong, not talking about profit.

Can someone check it for me, maybe I'm doing something wrong?


 
igorbel:

Passed when I added m_request.expiration =0, even though it says so in help:

Always initialize all variables and structures with zeros immediately after declaration. You had some rubbish in the expiration field, so you got an error.

MqlTradeRequest   m_request;         
MqlTradeCheckResult m_check_result; 

ZeroMemory(m_request);
ZeroMemory(m_check_result);
// теперь заполняйте нужные поля
 
Sergei Vladimirov:

Always initialise all variables and structures with zeros immediately after declaration. You had some rubbish in the expiration field, that's why you got the error.

Thank you. But I have abandoned OrderCheck(), it's almost useless function on FORTS at least. First of all, it gives unclear results. But even when the values are more or less correct, there is always a probability that the order will be rejected on the exchange. That is why we have to look at the order statusORDER_STATE_REJECTED and also see the comment. Then we have to decrease the volume in the order and send it again. Of course, all this does not make trading any faster, but what can we do?
Reason: