Questions from Beginners MQL5 MT5 MetaTrader 5 - page 847

 
Vitaly Muzichenko:

Perhaps you want the terminals with the graphics to send the markup to a web server and the others to receive it and display it on the chart. It's not an easy task, but it's doable

How can I do it or what should I read to learn how to do it? Is the markup automatically sent and accepted by other users or does it need to be uploaded as templates each time?
 
Илья:
How do I do this or what should I read to find out how this can be done? Is the markup automatically sent and accepted by other users or does it need to be uploaded separately each time as templates?

I think you need a small button, and after you've made a marking, press it and send it. On receivers it is the same, if you want to get a markup, then press the second button. Total 2 buttons on the graph, and there is no resource cost to constantly monitor it

 

How can I limit the placing of orders if there is always one position in the market after activating limit orders?

in forex, I used to check the number of orders - positions

if( CalculateBUYPositions()==1)
//// 
 int CalculateBUYPositions()
  {
   int total=0;
//ENUM_ORDER_TYPE   order_type=ORDER_TYPE_BUY;
   for(int i=PositionsTotal()-1;i>=0;i--)
      if(m_position.SelectByIndex(i)) // selects the position by index for further access to its properties
         if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)
                   if(m_position.PositionType()==POSITION_TYPE_BUY)
                  
              {
            total++;
            }
//---
   return(total);
  }
  //

Limit orders must be set if there is only one position

How can I replace this condition?

 
lil_lil:

How can I limit the placing of orders if there is always one position in the market after activating limit orders?

in forex, I used to check the number of orders - positions

Limit orders must be set if there is only one position

how can we replace this condition?

The question is not clear. You are confusing the orders and the positions.

The code "CalculateBUYPositions()" you cited calculates the number of BUY positions.


Please rephrase your question.

 
Vladimir Karputov:

The question is not clear. You are confusing orders and positions.

The code you cited, "CalculateBUYPositions()" calculates the number of BUY POINTS.


Re-phrase your question.

On forex, if I have one position I place a limit order and limit orders are activated, the number of positions increases and the EA does not place more Limits.

On forex, if there is one position limit and all limit orders are activated the number of positions increases and no more limit orders are placed. I need, an equal, alternative to the condition, -- "if there is one position" CalculateBUYPositions()==1

 
lil_lil:

On forex if there is one position I place a limit order, limit orders are activated the number of positions increases, no more limiters are placed by the EA.

On forex if there is one position the limit order is activated the number of positions increases and no more limit orders are placed by the EA. I need, an equal, alternative to the condition, -- "if there is one position" CalculateBUYPositions()==1

No, it isn't. To clarify, there is already one position on the current symbol:

  • On hedge accounts, once the pending order triggers, there will be ONE MORE position
  • on netting accounts after the pending order triggering
    • if the pending order was for the current symbol then:
      • the existing position will increase
      • an existing position will be decreased
      • an existing position will roll over
      • the existing position will reverse


To clarify your question: which account type you are looking for and WHAT you need to track.

 
lil_lil:

How can I limit the placing of orders if there is always one position in the market after activating limit orders?

in forex, I used to check the number of orders - positions

Limit orders must be set if there is only one position

How can this condition be changed?

This can be determined by the number of trades or the number of orders involved in the opening and modification of a position. You just need to select the history for the ticket of the position and check the number. If there is a variant that the position has added volume and then was partially closed by an opposite limit order or otherwise, we will need to loop through the trades and count the types of deals as DEAL_ENTRY_IN and/or other types.

Документация по MQL5: Торговые функции / HistorySelectByPosition
Документация по MQL5: Торговые функции / HistorySelectByPosition
  • www.mql5.com
Не следует путать между собой ордера из торговой истории и действующие отложенные ордера, которые отображаются на вкладке "Торговля" в панели "Инструменты". Список ордеров, которые были отменены или привели к проведению торговой операции, можно посмотреть  в закладке "История" на панели "Инструменты" клиентского терминала. Функция...
 
Thank you, I compare the position's lot with the starting lot, if they are not equal I exit.
 

Second day remaking the robot from MT4 to MT5. Made setting of pending orders - it works. Help on MqlTradeRequest:

   else if(orderType==ORDER_TYPE_BUY_STOP)
     {
      request.type =ORDER_TYPE_BUY_STOP;                                // тип ордера
      price        =SymbolInfoDouble(Symbol(),SYMBOL_ASK)+offset*point; // цена для открытия 
      request.price=NormalizeDouble(price,digits);                      // нормализованная цена открытия 
     }
   else if(orderType==ORDER_TYPE_SELL_STOP)
     {
      request.type     =ORDER_TYPE_SELL_STOP;                           // тип ордера
      price=SymbolInfoDouble(Symbol(),SYMBOL_ASK)-offset*point;         // цена для открытия 
      request.price    =NormalizeDouble(price,digits);                  // нормализованная цена открытия 
     }

In both cases Ask - looks like an error. In second case for SELL_STOP it would be better to use Bid ???

 
STARIJ:

Second day remaking the robot from MT4 to MT5. Made setting of pending orders - it works. Help on MqlTradeRequest:

In both cases Ask - looks like an error. In second case, Bid would be better for SELL_STOP.


SELL opens by BID and closes by ASK