A futures trade opens at Last price, not at Bid or Ask. Is this normal? - page 2

 

Roman and Alexey Viktorov, thanks for your help.

After opening a trade I decided to simply check if the real and calculated TP and SL distances are the same. If they do not coincide, I try to reset them in OnTrade() function. As a result, distances between real open price and TP and SL become correct. What is surprising is that such slippage is the norm for this symbol. The code is triggered almost at every trade opening.

//+------------------------------------------------------------------+
//|                          OnTrade()                               |
//+------------------------------------------------------------------+
void OnTrade()
  {
   if(HistoryDealSelect(last_trade_ticket))
     {
      // сделка выделилась успешно
      ulong pos_id = HistoryDealGetInteger(last_trade_ticket, DEAL_POSITION_ID);
      // идентификатор позиции сохранён
      if(HistorySelectByPosition(pos_id) && HistoryDealsTotal() == 1)
        {
         // история позиции сформирована
         // позиция состоит из одной сделки
         if(PositionSelectByTicket(pos_id))
           {
            // позиция выделена
            string symbol = PositionGetString(POSITION_SYMBOL);
            double pos_op = PositionGetDouble(POSITION_PRICE_OPEN);
            double pos_tp = NormalizeDouble(PositionGetDouble(POSITION_TP), _Digits);
            double pos_sl = NormalizeDouble(PositionGetDouble(POSITION_SL), _Digits);
            long pos_type = PositionGetInteger(POSITION_TYPE);
            long pos_mag = PositionGetInteger(POSITION_MAGIC);
            // параметры позиции получены
            int tp = int(GlobalVariableGet(global_tp));
            int sl = int(GlobalVariableGet(global_sl));
            double calc_tp_price = 0;
            double calc_sl_price = 0;
            if(pos_type == POSITION_TYPE_BUY)
              {
               // покупка
               // расчёт корректных тп и сл
               if(tp > 0)
                  calc_tp_price = NormalizeDouble(pos_op + tp * _Point, _Digits);
               if(sl > 0)
                  calc_sl_price = NormalizeDouble(pos_op - sl * _Point, _Digits);
              }
            if(pos_type == POSITION_TYPE_SELL)
              {
               // продажа
               // расчёт корректных тп и сл
               if(tp > 0)
                  calc_tp_price = NormalizeDouble(pos_op - tp * _Point, _Digits);
               if(sl > 0)
                  calc_sl_price = NormalizeDouble(pos_op + sl * _Point, _Digits);
              }
            if(pos_tp != calc_tp_price || pos_sl != calc_sl_price)
              {
               // обнаружен факт проскальзывания
               // исправить тейк и стоп
               MqlTradeRequest request;
               MqlTradeResult result;
               ZeroMemory(request);
               ZeroMemory(result);
               request.action = TRADE_ACTION_SLTP;
               request.position = pos_id;
               request.symbol = symbol;
               request.magic = pos_mag;
               request.tp = calc_tp_price;
               request.sl = calc_sl_price;
               if(!OrderSend(request, result) || result.retcode != TRADE_RETCODE_DONE)
                  Print("Ticket:", pos_id, " Error: ", ResultRetcode(result));
              }
           }
        }
     }
   last_trade_ticket = 0;
  }
//+------------------------------------------------------------------+
 
Good topic. Thank you and don't delete it. When I tried arbitrage, a lot of questions came up which are answered here
 
Oleg Remizov:

Roman and Alexey Viktorov, thanks for your help.

After opening a trade I decided to simply check if the real and calculated TP and SL distances are the same. If they do not coincide, I try to reset them in OnTrade() function. As a result, distances between real open price and TP and SL become correct. What is surprising is that such slippage is the norm for this symbol. The code is triggered almost at every trade opening.

Try to execute a deal in a limit order instead of the market price, but specify the best Ask price when buying or the best Bid price when selling. The order should be immediately executed at the stated price, unless, of course, the Ask or Bid changes during this time.

 
Vitalii Ananev:

Try to execute the transaction not according to the market, but by a limit order, but the price in the order indicate the best Ask price when buying or the best Bid price when selling. The order should immediately execute at the stated price, unless of course the Ask or Bid changes during this time.

Limit orders are executed well. Sometimes even at a better price than the bid.

 
Oleg Remizov:

.... Even sometimes at a better price than in the application form.

So the prices have changed.

Here's a tip:) With a limit order you can open a position as if you were opening a market order, but you also adjust the slippage. Forex traders are used to placing limit orders below the Bid price. And limit sell orders should be placed above the Ask price. You can place a limit order to buy at the Ask price or higher. It will be executed at the next best price. For example, the Ask price in the market is 5,8,10,20,35. Sending a limit order to buy at 10 will initiate a trade at 5. If the security order contains a price change and the best price is at 20, your order will not be executed, but will show up in the pickets at 10. This way we have limited the size of possible slippage.

 
Vitalii Ananev:

So the prices have changed.

Let me tell you a tip:) With a limit order you can open a position as if you were opening a market order, but you also adjust the slippage. Forex traders are used to placing limit orders below the Bid price. And limit sell orders should be placed above the Ask price. You can place a limit order to buy at the Ask price or higher. It will be executed at the next best price. For example, the Ask price in the market is 5,8,10,20,35. Sending a limit order to buy at 10 will initiate a trade at 5. If the security order contains a price change and the best price is at 20, your order will not be executed, but will show up in the pickets at 10. This way we have limited the possible slippage.

This is not a "how-to", but the principle of exchange execution. ))
That's why I told Aleh earlier, to understand how the exchange orders work.
By understanding how they work, you can improve the quality of your deals.

And here's a tiphack for those who work in Quik.
In Quik, you can open differently directed positions for the same instrument during the day.
Now that's a good one))
 
Roman:

It's not a smart trick, it's the principle of exchange execution. ))
That's why I told Oleg earlier, to understand how exchange orders work.
Understanding how they work, you can improve the quality of your deals.

Here's a smart trick for those who work in Quik.
In Quik, you can open different positions for one instrument during the day.
Now, this is a good know-how.)

I wrote it as a joke about this money trick with a smiley in the end.

But I did not know about the multi-directional positions in the Quick. Does the exchange allows you to do this?

 
Vitalii Ananev:

I wrote that as a joke about the trick with a smiley face at the end.

But I didn't know about the multi-directional positions in QuickBooks. Does the exchange allows you to do this?

I do not know who allows it)) The exchange, or the quick exchange servers.
Ordinary positions can be held until the main clearing, at clearing they will be closed, in equal volume.
That is, if 2 are long, 1 is short, then 1 will remain long after clearing.
As a matter of fact, during the day you can fix the loss, but not to realize it, and if you expect a bounce, you can reduce the loss.
And if the reversal occurs, you can get the profit from the trade. In general, in good hands, it is a good tool.

 
Roman:

I don't know who lets you do that )) The exchange, or the quickie servers.
Divergent positions can be held until the main clearing, at clearing they will be closed, in equal volume.
That is, if 2 are long, 1 is short, then 1 will remain long after clearing.
As a matter of fact, during the day you can fix the loss, but not to realize it, and if you expect a bounce, you can reduce the loss.
And if the reversal occurs, you can get the profit from the trade. In general, it is a good tool in skilful hands.

I see. I do not trade intraday, only long and long.

 
Oleg Remizov:

Specification of the trading instrument:

What marketplace is this traded on?

Reason: