Stock market. Stocks. Speed of trade order execution. - page 14

 
Dmitriy Skub #:
That's in terms of overheads. But in terms of arbitrage?

in terms of costs, of course.

you will pay for shorting the stock

 
Dmitriy Skub #:
That's in terms of overheads. And in terms of arbitrage?

Classic arbitrage, is:

Buying(by no means selling) shares and simultaneously selling stock-size futures.

exp_data.fut_equity = long(exp_data.fut_contr * exp_data.fut_contr_size);

=

exp_data.spot_equity = long(exp_data.spot_lot * exp_data.spot_lot_size);
exp_data.fut_equity = exp_data.spot_equity


If you short a stock, Opener will turn on the meter at 23% p.a.
 

But I wonder what will happen if request.action = TRADE_ACTION_PENDING; is replaced by request.action = TRADE_ACTION_DEAL in the Stock structure;


ulong SpotSetOrder(const long vol, const double price, const ulong magic, const int dir)
{
  MqlTradeRequest request = {}; 
  MqlTradeResult  result = {};
//--- Fill structure
  request.magic = magic;
  request.symbol = Symbol();
  request.volume = double(vol); 
  request.type_filling = ORDER_FILLING_RETURN;
  request.type_time = ORDER_TIME_DAY;
  request.action = TRADE_ACTION_PENDING;
  request.price = price;
  request.comment = "Отложенный ордер";
  if (dir == BUY) request.type = ORDER_TYPE_BUY_LIMIT;
   else
  if (dir == SELL) request.type = ORDER_TYPE_SELL_LIMIT;
   else return(0);
  if(OrderSend(request, result) == true)
  {
    if((result.retcode == TRADE_RETCODE_PLACED) || (result.retcode == TRADE_RETCODE_DONE))
    {
      return(result.order);
    }
    else Print("Ордер не размешен на Бирже!");
  }
  else Print("Ордер не отправлен!");
  return(0);
}


Will the order be executedfaster or not?

 
prostotrader TRADE_ACTION_PENDING; is replaced by request.action = TRADE_ACTION_DEAL in the Stock structure;



Will the order be executedfaster or not?

If you specify the current price from the market, it won't be faster. But slippage may occur. Anyway, I observed it on the demo-openers.

 
Alexey Viktorov #:

If you are quoting the current price from the cup, I don't think it will go any faster. But slippage can happen. At least, I observed it in the demo mode.

TRADE_ACTION_PENDING - set a trade order for execution of a deal at specified conditions (pending order )

TRADE_ACTION_DEAL - set a trade order for immediate execution of a deal at specified parameters (put a market order)

It seems that TRADE_ACTION_DEAL order should be executed faster.

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

TRADE_ACTION_PENDING - Place a trade order to execute a trade at specified conditions (pending order )

TRADE_ACTION_DEAL - set a trade order for immediate execution of a deal with specified parameters (put market order)

It seems that TRADE_ACTION_DEAL order should be executed faster.

There is no way to do without an order. Immediate execution means only at the current price. Later, we can get a list of orders by position ID, but the properties will not be all. I do not remember what else is missing right now, but certainly not the price of the order.

Here we have one pending position on the demo. This code

/********************Script program start function*******************/
void OnStart()
 {
  int posTotal = PositionsTotal();
  ulong posTicket = PositionGetTicket(0);
  long posID = PositionGetInteger(POSITION_IDENTIFIER);
  HistorySelectByPosition(posID);
  int ordTotal = HistoryOrdersTotal();
  for(int i = 0; i < ordTotal; i++)
   {
    ulong ordTicket = HistoryOrderGetTicket(i);
    Print("тикет ордера ", ordTicket,
          " время ", (datetime)HistoryOrderGetInteger(ordTicket, ORDER_TIME_SETUP), 
          " цена ", HistoryOrderGetDouble(ordTicket, ORDER_PRICE_OPEN),
          " установлен ", EnumToString((ENUM_ORDER_REASON)HistoryOrderGetInteger(ordTicket, ORDER_REASON)));
   }
 }/*******************************************************************/

Result

2022.04.08 09:30:28.996 !00 (EURUSD,M1) тикет ордера 178273170 время 2022.03.21 18:28:09 цена 0.0 установлен ORDER_REASON_EXPERT

This is not forex...


Added:

Well yeah, I guess I didn't get it right straight away...

In this case you have to understand that if you put a price equal to the best price in the market window into a pending order, it is equivalent to setting a market order.

 
Alexey Viktorov #:

In this case, it should be understood that if you put a price equal to the best price in the market, it is equivalent to placing a market order.

This is if there is enough volume in the market.

 
JRandomTrader #:

This is if there is enough volume in the glass.

This all has to be checked in real life. Probably, if there is not enough volume at the best price, it will be added from the next one.

But if we are talking about the work of the Expert Advisor, nothing prevents us from putting the condition that, if there is not enough volume at the best price, we can open the current volume and then open the next best price with the remaining volume. You can do this as many times as you like in the do while loop.

 
Alexey Viktorov #:

This all has to be checked in real life. It is likely that if there is not enough volume at the best price, the next best price will be added.

But if we are talking about the work of the Expert Advisor, nothing prevents us from stipulating that if we do not have enough volume at the best price, then open the current volume and then reopen the next best price with the rest of the volume. You can do it as many times as you like in the do while loop.

In the case of insufficient volume depends on the type of filling - for RETURN the limit with the remainder will be set in the cup.

By the way, if we place a market order with RETURN, TRADE_ACTION_DEAL and zero price then we can see another transaction TRADE_TRANSACTION_REQUEST with TRADE_ACTION_PENDING and price at the slat.

Regarding the loop over the bar - this will only work for low-liquid ones, otherwise the speed won't be enough. I've written a scalper with speed squeeze, with asynchronous sending, avoiding heavy operations, working with string and no history calls as much as possible. But still, with my ping of 10-12 ms, it can't keep up with the glass.

 

Strange as it may seem, but it works many times faster with TRADE_ACTION_DEAL, except that the price will always be better,

despite the fact that it is set to the maximum (minimum) in the cup.


Reason: