Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1233

 
Any advice - I'm doing forward optimisation, but for some reason there are no 2 options by criterion in the optimisation results. as I understand, there should be back and forward data. there's nothing similar in the context menu either. how can I see back and forward data from the optimisation results?
 

A word of advice to a beginner.

When a Start event occurs in the script, it is handled by the OnStatr() function.

I have written a script called Print_1.

void OnStart()
  {
   int x, y, z;
   x=5;
   y=4;
   z=x+y;
   printf(IntegerToString(z));
  }

I think this function should print to terminal log number 9 when user clicks on Print_1 script. But nothing happens.

How and where in the terminal to see output z on the screen? What is the source of the Start event? How to start it so that number 9 finally appears on the screen? And run it from the terminal.

Документация по MQL5: Программы MQL5 / События клиентского терминала
Документация по MQL5: Программы MQL5 / События клиентского терминала
  • www.mql5.com
Сразу же после того, как клиентский терминал загрузит программу (эксперт или пользовательский индикатор) и запустит процесс инициализации глобальных переменных, будет послано событие Init, которое обрабатывается функцией OnInit(), если она есть. Это событие также генерируется после смены финансового инструмента и/или периода графика, после...
 
How can I track the moment when an order triggers in order to place another order in the same direction and at a certain distance? (on mql5)
 
MaxTr:

A word of advice to a beginner.

When a Start event occurs in the script, it is handled by the OnStatr() function.

I have written a script called Print_1.

I think this function should print to terminal log number 9 when user clicks on Print_1 script. But nothing happens.

How and where in the terminal to see the output z on the screen? What is the source of the Start event? How to start it so that number 9 finally appears on the screen? And I want to run it from the terminal.

Print and printf print the information to the "Toolbox" window, to the "Experts" tab.

Print

Prints a message into the journal

PrintFormat

Formats and prints the sets of characters and values into a log file according to a preset format


Displayed on the screen via

Comment

Outputs a message in the upper left corner of the price chart

Документация по MQL5: Общие функции / Print
Документация по MQL5: Общие функции / Print
  • www.mql5.com
Данные типа double выводятся с точностью до 16 десятичных цифр после точки, при этом данные могут выводиться либо в традиционном либо в научном формате – в зависимости от того, как запись будет наиболее компактна. Данные типа float выводятся с 5 десятичными цифрами после точки. Для вывода вещественных чисел с другой точностью либо в явно...
 
Sysmart:
How can I track the moment when an order triggers in order to place another order in the same direction and at a certain distance? (on mql5)


//+------------------------------------------------------------------+
//| TradeTransaction function                                        |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction &trans,
                        const MqlTradeRequest &request,
                        const MqlTradeResult &result)
  {
//--- get transaction type as enumeration value
   ENUM_TRADE_TRANSACTION_TYPE type=trans.type;
//--- if transaction is result of addition of the transaction in history
   if(type==TRADE_TRANSACTION_DEAL_ADD)
     {
      if(HistoryDealSelect(trans.deal))
         m_deal.Ticket(trans.deal);
      else
         return;
      if(m_deal.Symbol()==m_symbol.Name() && m_deal.Magic()==InpMagic)
        {
         if(m_deal.DealType()==DEAL_TYPE_BUY || m_deal.DealType()==DEAL_TYPE_SELL)
           {
            if(m_deal.Entry()==DEAL_ENTRY_IN)
 
Vladimir Karputov:


I've heard it's not a good idea to doOnTradeTransaction, as it doesn't always work

 
If a hedge account, is it possible to track the triggering of an order by changing the number of orders?
Документация по MQL5: Торговые функции / PositionsTotal
Документация по MQL5: Торговые функции / PositionsTotal
  • www.mql5.com
Торговые функции / PositionsTotal - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
New problem, need to select the last open position in the hedge
 
Sysmart:
New problem, you need to select the last open position in the hedge

OnTradeTransaction+ variable declared in EA header. The variable stores the type of the last position opened. It is of long type and initialized with value '-1'. In OnTradeTransaction, you catch the moment when a position was opened and write it into the variable.

Then you check this variable in your code - if it is equal to '-1', then go through the loop and compare the time when each position was opened. Find the 'youngest' position andwrite it into the variable. If the variable is not equal to '-1' - then you compare it with the position type.

Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
В языке MQL5 предусмотрена обработка некоторых предопределенных событий. Функции для обработки этих событий должны быть определены в программе MQL5: имя функции, тип возвращаемого значения, состав параметров (если они есть) и их типы должны строго соответствовать описанию функции-обработчика события. Именно по типу возвращаемого значения и по...
 
Can you tell me how to put money into MT5?