Questions from Beginners MQL5 MT5 MetaTrader 5 - page 390

 

Karputov Vladimir:
Пожалуйста, всегда уточняйте для какой версии MQL4 или MQL5 Ваш вопрос. 

MQL5

 

Gentlemen programmers!

In MQL5, how can I synchronize bars on different currency pairs in time?

It used to be "iBarShift", but how was it replaced?

 
new-rena:

Gentlemen programmers!

In MQL5, how can I synchronize bars on different currency pairs by time?

It used to be "iBarShift", but how was it replaced?

CopyTime()

 
pako:

Thanks, I found it. I did what I wanted in a few minutes. great article. kudos to the developer!

https://www.mql5.com/ru/articles/81

//+------------------------------------------------------------------+
//| --- ФУНКЦИЯ iBarShif t
//+------------------------------------------------------------------+   
int iBarShift(string symbol,int tf,datetime time)
   {
      if(time<0) return(-1);
      ENUM_TIMEFRAMES timeframe=TFMigrate(tf);
      datetime Arr[],time1;
      CopyTime(symbol,timeframe,0,1,Arr);
      time1=Arr[0];
      if(CopyTime(symbol,timeframe,time,time1,Arr)>0)
        {
         if(ArraySize(Arr)>2) return(ArraySize(Arr)-1);
         if(time<time1) return(1);
         else return(0);
        }
      else return(-1);
   }
Переход с MQL4 на MQL5
Переход с MQL4 на MQL5
  • 2010.05.11
  • Sergey Pavlov
  • www.mql5.com
Данная статья, построенная в форме справочника по функциям MQL4, призвана помочь переходу с MQL4 на MQL5. Для каждой функции языка MQL4 приведено описание и представлен способ ее реализации на MQL5, что позволит вам значительно ускорить перевод своих программ с MQL4 на MQL5. Для удобства функции разбиты на группы, как в документации по MQL4.
 

Hello!

Can you please advise how to get information about open and closed trades in MQL5 Expert Advisor code (what price was opened, what were the TP and SL)?

And is there any built-in function or library that returns an array with n latest valuesof moving average(preferably weighted or exponential)?

 
Сергей Михеев:

Thank you!

And please advise, if there is any such a construction in MQ4 as an associative array with text keys, for example: Array["Here is the key!"]?

Yes, there is. Read the article on this subject:"MQL5 Recipes - Implementing an associative array or dictionary for quick access to data".

Karputov Vladimir:
The elements of an array are accessed by an index. The index is the whole int type.

I recommend you to read the article too.

 
Сергей Михеев:

Good day to all!

I need to get from the input field in the EA window the timeframe selected by the user from the drop-down list. How to use it in the function, I'm struggling with it for the second day in a row, please advise me)!

Code:

input enum timeFrame {
Hour_1 = 60,
Hour_4 = 240,
Day_1 = 1440,
Week_1 = 10080

};

iADX(currencySelect, THIS IS HOW TO INSTALL SELECTED DATA!, ADXparam, PRICE_CLOSE, MODE_MINUSDI,2)

Thank you!

Do not reinvent the wheel. Make the ENUM_TIMEFRAMES enumeration as an input parameter.

Karputov Vladimir:

Insert code correctly on the forum

Here is an example of a script that uses your enumeration:

Why do you advise a wrong approach? You are well aware that it is nonsense to invent your own enumeration of timeframes.

 
People!!! I do not understand the language in which experts and scripts are written in MT4 these days. If I started to replace all functions in my code with MQL5 functions, MetaEditor from MT4 terminal, has not recognized all functions as functions! For example this function

ulong a =OrderGetTicket( 1); // number in the order list

MetaEditor does not consider thisfunction to be a function. And the parameter(ORDER_POSITION_ID) in the function ---> positionID = OrderGetInteger(ORDER_POSITION_ID); it is not considered as parameter at all...


 
Hi, can you tell me why my debugging buttons are not active in metaeditore????source is inserted
 
Kira27:
People!!! I do not understand the language in which experts and scripts are written in MT4 these days. If I started to replace all functions in my code with MQL5 functions, MetaEditor from MT4 terminal, has not recognized all functions as functions! For example this function

ulong a =OrderGetTicket( 1); // number in the order list

MetaEditor does not consider thisfunction to be a function. And the parameter(ORDER_POSITION_ID) in the function ---> positionID = OrderGetInteger(ORDER_POSITION_ID); it is not considered as parameter at all...


Most likely, the above functions are user-defined and MU does not need to know them. You have to declare and call them correctly yourself.
Reason: