Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1249

 

Hello.

Need to adapt one of the standard indicators that are hanging in the terminal. Couldn't find how to access their code and where do they even lie?

 
Sergey:

Hello.

Need to adapt one of the standard indicators that are hanging in the terminal. I cannot find how to access their code and where do they even exist?

You will not get access to the code of standard indicators. But there are examples:

\MQL5\Indicators\Examples\

 
Artyom Trishkin:

You will not have access to the code of the standard indicators. But there are examples:

\MQL5\Indicators\Examples\

Thanks for the tip.

 
Hi all. Is it possible to choose a specific period in mql5 to study statistics? Or is it kept exclusively for the entire period of the account's life?
 

When setting alert

How can I set the default alert to be something other than alert, for examplealert2?

In which file do I need to edit?


 
Vitaly Muzichenko:

When setting alert

How can I set the default alert to be something other than alert, for examplealert2?

In what file need to make changes?


Apparently in the Sounds folder. Found it where the terminal is installed. НЕ в папке C:\Users\yastremskiiva\AppData\Roaming\MetaQuotes\Terminal\99193835FC75DE8874B99F9A3B93F15E

And judging by the alphabetical order, rename alert2 to be more alphabetical than alert

 
Valeriy Yastremskiy:

Apparently in the Sounds folder. Found it where the terminal is installed. НЕ в папке C:\Users\yastremskiiva\AppData\Roaming\MetaQuotes\Terminal\99193835FC75DE8874B99F9A3B93F15E

And judging by the alphabetical order, rename alert2 to be more alphabetical than alert

Yes, as an option, but not quite what I'd like.

Thank you!

 

Need to find the profit of the last closed order. I have written a function:

double LastProfitOrder()
{
   int      i;
   int      total  = HistoryDealsTotal();
   ulong    ticket;
   datetime time; 
   long     type;
   string   symbol; 
   ulong    magic; 
   double   profit;
   double   profits = 0;
   datetime times   = 0;
   
   HistorySelect(0, TimeCurrent());
   
   for(i = total - 1; i >= 0; i--)
   {
      ticket = HistoryDealGetTicket(i);
      time   = (datetime)HistoryDealGetInteger(ticket, DEAL_TIME); 
      type   = HistoryDealGetInteger(ticket, DEAL_TYPE);
      symbol = HistoryDealGetString(ticket, DEAL_SYMBOL); 
      magic  = HistoryDealGetInteger(ticket, DEAL_MAGIC); 
      profit = HistoryDealGetDouble(ticket, DEAL_PROFIT); 
         
      if(symbol == Symbol() && magic == Magic)
      {
         if(type == DEAL_TYPE_BUY || type == DEAL_TYPE_SELL)
         {
            if(time > times)
            {
               profits = profit;
               times   = time;
            }
         }
      }
   }
   return(profits);
}

As long as the orders were opened via a "portlet" in OnTick() (MqlTick latestPrice;MqlTradeRequest request; ... etc.), the function worked. As soon as I started to open orders using #include <Trade\Trade.mqh> and wrote out a separate function:

void OpenOrderBuy()
{
   double open = NormalizeDouble(iHigh(NULL, 0,1) + (VO+sp)*_Point, _Digits);
   double sl   = NormalizeDouble(open - SL*_Point, _Digits);
   double tp   = NormalizeDouble(open + TP*_Point, _Digits);
   
   if(!m_trade.BuyStop(GetLots(), open, _Symbol, sl, tp, ORDER_TIME_SPECIFIED, DateExp()))
   {
      Print("Метод BuyStop() потерпел поражение. Код возврата = ", m_trade.ResultRetcode(),
            ". Описание кода: ", m_trade.ResultRetcodeDescription());
   }
   else
   {
      Print("Метод BuyStop() исполнен успешно. Код возврата = ", m_trade.ResultRetcode(),
            " (", m_trade.ResultRetcodeDescription(),")");
   }
}

The profit finding function stopped working (although orders were opening correctly). I have returned the "TypoScript" - it works again. Why such a ***? What is the difference? I have not found anything in include that would give a closed order profit. For example, #include <Trade\HistoryOrderInfo.mqh> contains everything but I haven't found the order profit.

Документация по MQL5: Константы, перечисления и структуры / Структуры данных / Структура торгового запроса
Документация по MQL5: Константы, перечисления и структуры / Структуры данных / Структура торгового запроса
  • www.mql5.com
Взаимодействие клиентского терминала и торгового сервера для проведения операций постановки ордеров производится посредством торговых запросов. Запрос представлен специальной предопределенной структурой MqlTradeRequest, которая содержит все поля, необходимые для заключения торговых сделок. Результат обработки запроса представлен структурой...
 
Youri Lazurenko:

As long as the orders were opened via a "spoiler" in OnTick() (MqlTick latestPrice;MqlTradeRequest request; ... etc.), the function worked. Once I started opening orders using #include <Trade\Trade.mqh>, I wrote out a separate function:

Don't forget toset the Expert Advisor ID

   m_trade.SetExpertMagicNumber(InpMagic);
Документация по MQL5: Стандартная библиотека / Торговые классы / CTrade / SetExpertMagicNumber
Документация по MQL5: Стандартная библиотека / Торговые классы / CTrade / SetExpertMagicNumber
  • www.mql5.com
SetExpertMagicNumber(ulong) - CTrade - Торговые классы - Стандартная библиотека - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Vladimir Karputov:

Don't forgetto set the expert ID

Thank you. I have not built such labyrinths in mql5. Instead of coming straight to the goal, you have to take some detours, through a bunch of branches, dead ends and obstacles. Language for the sake of language.

Reason: