Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1433

 
Alexey Petrov #:

Hello,

Try searching the market for ready-made solutions - https://www.mql5.com/fr/search#!keyword=money%20management&module=mql5_module_market

You can also order a customised solution from Freelance - https://www.mql5.com/fr/job

Hello and thank you for your reply. I've been able to create a script that meets my expectations, but unfortunately there are still two errors that I can't understand or correct. Would you know who to contact for a little help? It's just two lines of code that register as errors after compilation...
 
Happy New Year! Which windows is better for MT5 10 or 11? Sitting on AMD 5900X laptop
 

Hello everyone and happy new year! Can you tell me: how can I realise that my script would use an indicator from the market?

More specifically:
there is an indicator "Automatic Trendline" in the market. I want to make a robot based on it, which would open or close a position at the moment when the price crosses these lines on the indicator (well, and under specified additional conditions).

 
Rad89 #:

Hello everyone and happy new year! Can you tell me: how can I realise that my script would use an indicator from the market?

More specifically:
there is an indicator "Automatic Trendline" in the market. I want to make a robot based on it, which would open or close a position at the moment when the price crosses these lines on the indicator (well, and under specified additional conditions).

No problem for myself. For the market or CodeBase you can not use someone else's crafts from the market ...

 
Alexey Viktorov #:

For yourself, no problem. You can't use someone else's crafts from the marketplace or CodeBase...

For yourself. I don't know how to do it. I can't find the code in open source. Or how to screw into my code that it would catch the position of lines.

 

Hello, @Rad89

You need iCustom() and CopyBuffer() functions.

Here is an example of adding an indicator downloaded from the Market to an Expert Advisor

// Глобальная переменная для хендла индикатора
int tlHandle;

int OnInit() {
   // Создаем хендл индикатора
   tlHandle = iCustom(Symbol(), PERIOD_CURRENT, "Market\\Automatic Trendlines", false, 5, 15, clrRed, clrBlue, 2, "My Support", "My Resistance");
   
   // Можем добавить индикатор на график, если хотим. 
   // Для использования в расчетах это необязательно
   ChartIndicatorAdd(ChartID(), 0, tlHandle);

   // Вызовем один раз OnTick(), чтобы на выходных у нас что-то в логе отобразилось
   OnTick(); 
   
   return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason) {}

void OnTick() {
   // Объявляем массивы для буферов индикатора
   double tlBuffer0[], tlBuffer1[]; // ,tlBuffer1, ...
   
   int res;
   
   // Копируем нужное количество значений из индикаторных буферов в массивы
   res = CopyBuffer(tlHandle, 0, 0, 100, tlBuffer0);
   res = CopyBuffer(tlHandle, 1, 0, 100, tlBuffer1);
   
   // У разных индикаторов различное количество индикаторных буферов, 
   // числа из которых используются для построения линий, значков, цветовых меток на графике
   // Сколько их у данного индикатора и как используются их числа исследуйте самостоятельно
   
   // res = CopyBuffer(tlHandle, 2, 0, 100, tlBuffer2);
   
   // Пользуемся полученными значениями
   ArrayPrint(tlBuffer0);
   ArrayPrint(tlBuffer1);
}
Документация по MQL5: Технические индикаторы / iCustom
Документация по MQL5: Технические индикаторы / iCustom
  • www.mql5.com
iCustom - Технические индикаторы - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Hello. There is an Enum.
enum ENUM_NAME
  {
   ENUM_1,
   ENUM_jsdf
   ....
   ENUM_FEF;   
  };
How to allocate memory for the E_NAME[] array so that there is enough memory for all possible ENUM_NAME values (without repetitions) ?
ENUM_NAME     E_NAME[];

And initialise E_NAME[] with all possible values ?

 

Hello, @pivomoe

If you are not going to force assigning numeric values to the enumeration items (judging by the example, you won't), you can do it like this:

// Объявляем перечисление
enum ENUM_NAME {
   ENAME_1,
   ENAME_JSDF,
   ENAME_ERT,
   ENAME_QWERTY,
   ENAME_FEF
};

// Обявляем константу, хранящую количество элементов перечисления
#define  ENUM_NAME_SIZE 5

// Массив для хранения элементов перечисления
ENUM_NAME     E_NAME[ENUM_NAME_SIZE];

int OnInit() {
   // Заполняем массив значениями, преобразуя к типу ENUM_NAME
   for(int i = 0; i < ENUM_NAME_SIZE; i++) {
      E_NAME[i] = (ENUM_NAME) i;
   }

   // Пользуемся массивом
   ArrayPrint(E_NAME);
   
   for(int i = 0; i < ENUM_NAME_SIZE; i++) {
      Print(EnumToString(E_NAME[i]));
   }
   
   return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason) {}

In this case, you will need to change also the constant storing the number of elements when adding elements to the enumeration.

Also, it is better to use the ENUM_ prefix only for the name of the enumeration itself, and use some other prefix for its elements. This convention is used in all standard MQL enumerations.

 
Yuriy Bykov #:

Hello, @pivomoe

If you won't force assigning numeric values to the enumeration items (judging by the example - you won't), you can do it like this:

In this case, you will need to change the constant storing the number of items when adding items to the enumeration as well.

Also, it is better to use the ENUM_ prefix only for the name of the enumeration itself, and use some other prefix for its elements. This convention is used in all standard MQL enumerations.

Thanks for your help. I've been using ENUM for so many years that it didn't even occur to me to read the help.

 
jeremy10p100 # :
Hello and thank you for your reply. I've been able to make a script that meets my expectations, but unfortunately there are still two errors that I can't understand or correct. Would you know who to contact for a little help? It's just two lines of code that register as errors after compilation...

You can create a freelance job and choose from the developers who apply for your job

https://www.mql5.com/fr/job

Applications de trading pour MetaTrader 5 à commander
Applications de trading pour MetaTrader 5 à commander
  • 2023.01.08
  • www.mql5.com
Le plus grand service de freelance avec des développeurs d'applications MQL5