Errors, bugs, questions - page 3163

 
Roman #:

There is no price on forex Last.
It must be such a thrashing ))

The solution is as follows.
Configure all the chart display properties as you like, and save it in the template as default.tpl

How do you do this?

I don't understand why this last price line was added, in a practical sense it's useless.

 
user4321 #:

how do I do it?

PCM on graphic -> Templates -> Save template
File name: default.tpl

 
In some cases (I never found a pattern), when compiling code with an unuseddeclared variable,MetaEditor5 does not warn about the unused variable.
 

Forum on trading, automated trading systems & strategy testing

Any questions from newbies on MQL4 and MQL5, help and discussion on algorithms and codes

MrBrooklin, 2022.02.25 07:15

Good Morning, Dear Experts!

Today I've faced two more issues I don't understand, but this time they are in the code taken from the MQL5 Reference in its entirety. This time I didn't write anything myself, but just took a ready-made example.

I open MQL5 Reference / Constants, Enumerations and Structures / Data Structures / Structure of a Trade Request. I find it there:

Structure of the trade request
Modify Pending Order
Торговый приказ на модификацию уровней цен отложенного ордера. Требуется указание 7 полей:
    action
    order
    price
    sl
    tp
    type_time
    expiration
 Пример торговой операции TRADE_ACTION_MODIFY для модификации уровней цен отложенного ордера:

This is clear. I am followed by an example with the following code:

#define  EXPERT_MAGIC 123456  // MagicNumber эксперта
//+------------------------------------------------------------------+
//| Модификация отложенных ордеров                                   |
//+------------------------------------------------------------------+
void OnStart()
  {
//-- объявление и инициализация запроса и результата
   MqlTradeRequest request={};
   MqlTradeResult  result={};
   int total=OrdersTotal(); // количество установленных отложенных ордеров
//--- перебор всех установленных отложенных ордеров
   for(int i=0; i<total; i++)
     {
      //--- параметры ордера
      ulong  order_ticket=OrderGetTicket(i);                             // тикет ордера
      string order_symbol=Symbol();                                      // символ
      int    digits=(int)SymbolInfoInteger(order_symbol,SYMBOL_DIGITS);  // количество знаков после запятой
      ulong  magic=OrderGetInteger(ORDER_MAGIC);                         // MagicNumber ордера
      double volume=OrderGetDouble(ORDER_VOLUME_CURRENT);                // текущий объем ордера
      double sl=OrderGetDouble(ORDER_SL);                                // текущий Stop Loss ордера
      double tp=OrderGetDouble(ORDER_TP);                                // текущий Take Profit ордера
      ENUM_ORDER_TYPE type=(ENUM_ORDER_TYPE)OrderGetInteger(ORDER_TYPE); // тип ордера
      int offset = 50;                                                   // отступ от текущей цены для установки ордера, в пунктах
      double price;                                                      // цена срабатывания ордера
      double point=SymbolInfoDouble(order_symbol,SYMBOL_POINT);          // размер пункта
      //--- вывод информации об ордере
      PrintFormat("#%I64u %s  %s  %.2f  %s  sl: %s  tp: %s  [%I64d]",
                  order_ticket,
                  order_symbol,
                  EnumToString(type),
                  volume,
                  DoubleToString(PositionGetDouble(POSITION_PRICE_OPEN),digits),
                  DoubleToString(sl,digits),
                  DoubleToString(tp,digits),
                  magic);
      //--- если MagicNumber совпадает, Stop Loss и Take Profit не заданы
      if(magic==EXPERT_MAGIC && sl==0 && tp==0)
        {
         request.action=TRADE_ACTION_MODIFY;                           // тип торговой операции
         request.order = OrderGetTicket(i);                            // тикет ордера
         request.symbol   =Symbol();                                   // символ
         request.deviation=5;                                          // допустимое отклонение от цены
        //--- установка уровня цены, тейк-профит и стоп-лосс ордера в зависимости от его типа
         if(type==ORDER_TYPE_BUY_LIMIT)
           {
            price = SymbolInfoDouble(Symbol(),SYMBOL_ASK)-offset*point; 
            request.tp = NormalizeDouble(price+offset*point,digits);
            request.sl = NormalizeDouble(price-offset*point,digits);
            request.price    =NormalizeDouble(price,digits);                // нормализованная цена открытия
           }
         else if(type==ORDER_TYPE_SELL_LIMIT)
           {
           price = SymbolInfoDouble(Symbol(),SYMBOL_BID)+offset*point; 
            request.tp = NormalizeDouble(price-offset*point,digits);
            request.sl = NormalizeDouble(price+offset*point,digits);
            request.price    =NormalizeDouble(price,digits);                 // нормализованная цена открытия
           }
         else if(type==ORDER_TYPE_BUY_STOP)
           {
           price = SymbolInfoDouble(Symbol(),SYMBOL_ASK)+offset*point; 
            request.tp = NormalizeDouble(price+offset*point,digits);
            request.sl = NormalizeDouble(price-offset*point,digits);
            request.price    =NormalizeDouble(price,digits);                 // нормализованная цена открытия
           }
         else if(type==ORDER_TYPE_SELL_STOP)
           {
           price = SymbolInfoDouble(Symbol(),SYMBOL_BID)-offset*point; 
            request.tp = NormalizeDouble(price-offset*point,digits);
            request.sl = NormalizeDouble(price+offset*point,digits);
            request.price    =NormalizeDouble(price,digits);                 // нормализованная цена открытия
           }
         //--- отправка запроса
         if(!OrderSend(request,result))
            PrintFormat("OrderSend error %d",GetLastError());  // если отправить запрос не удалось, вывести код ошибки
         //--- информация об операции   
         PrintFormat("retcode=%u  deal=%I64u  order=%I64u",result.retcode,result.deal,result.order);
         //--- обнуление значений запроса и результата
         ZeroMemory(request);
         ZeroMemory(result);
        }
     }
  }
//+------------------------------------------------------------------+

I'm trying to understand the line highlighted in yellow. A question arises right away: what does PositionGetDouble(POSITION_PRICE_OPEN) have to do with itif this example is related to pending orders? Maybe, there should be a line like this:

DoubleToString(OrderGetDouble(ORDER_PRICE_OPEN),digits)
This is the first point. The second issue comes up when I try to run this script on a chart with a BUY_STOP pending order I have set (though everything similar happens to other types of pending orders). So, what happens? Nothing happens! I do not see any modification of a pending order. Maybe, I do not understand something?

I only find this in the Experts tab:
2022.02.25 08:41:38.491 4 (EURUSD,M1)   #4727791  EURUSD  ORDER_TYPE_BUY_STOP  0.10  0.00000  sl: 0.00000  tp: 0.00000  [0]
Dear Experts, please help me to understand this example, why it is in the directory, but its code does not work?

Regards, Vladimir.

 
Good afternoon. Can you tell me how to withdraw a deposit to a card?
 
801765632 #:
Hello. Can you tell me how to withdraw the deposit to the card?

This is the website of the developer of the trading platform. It is not a broker, it is not a DC, there are no real trading accounts.

It clearly says so at the bottom of the page:


Please ask such questions of your broker - who did you transfer money to your trading account.

 
801765632 #:
Good afternoon. Can you tell me how to withdraw the deposit to the card?
Please contact the broker you opened a real trading account with.
 

Dear developers! Why in the second and third calls is (T* const Ptr) overloaded instead of (T* & Ptr)?

Is this a bug or a feature? b3213.


template <typename T>
void f1(T* const Ptr) {Print(__FUNCSIG__);}

template <typename T>
void f1(T* & Ptr) {Print(__FUNCSIG__);}


class X {};

void OnStart()
  {
   const X* Ptr = new X;

   f1(Ptr);                                //void f1<const X>(const X*&)
   f1((X*)Ptr);                            //void f1<X>(X*const)
   f1((const X*) Ptr);                     //void func_902::f1<const X>(const X*const)

   delete Ptr;
  }
 
Roman #:

PCM on graphic -> Templates -> Save template
File name: default.tpl

There is such a template by default. I replaced it. Didn't help, alas. It's still the same when switching to or from it.

Do you know how to write to the developers? Surely it has already been reported to them a few hundred times, well, I'll write again.

 

When scrolling, the header in the signals rides


Reason: