Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1417

 

good afternoon everyone.

please tell me how to solve the problem

there is a class that processes positions and orders and checks them with the database.

we need to pass STRUCTURES (string, double, int, string .....) from this class.

how can this be done

and if possible a link to an example

 
Sergey Li #:

good afternoon, everyone.

please tell me how to solve the problem

there is a class that processes positions and orders and checks them with the database

it is necessary to pass STRUCTURES (string, double, int, string .....) from this class.

how can this be done

and if possible a link to an example

There are examples in the standard library.

Документация по MQL5: Стандартная библиотека / Торговые классы / CTrade / Result
Документация по MQL5: Стандартная библиотека / Торговые классы / CTrade / Result
  • www.mql5.com
Result(MqlTradeResult&) - CTrade - Торговые классы - Стандартная библиотека - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
before sending an order we need to check when the last position on a symbol was opened, what will be faster to look in the history or in the global variable of the terminal?
 
lynxntech global terminal variable?

It can't be faster than in the variable. Only one correction: you can use the global variable of the terminal to save it when restarting the terminal, and look through the history in OnInit(). But when you go to OnTick(), this value must be in the global level variable, but not in the global variable of the terminal.

 
Alexey Viktorov #:

It cannot be faster than in a variable. Only one correction: you can use the global variable of the terminal to save it when restarting the terminal, and dig through the history in OnInit(). But when you go to OnTick(), this value must be in the global level variable, but not in the global variable of the terminal.

Is the global variable of the Terminal so slow, because it should be stored in the same memory as a normal one, it is not a huge amount of information that is requested from the disc when necessary.

 
lynxntech #:

Is a global variable so slow, because it should be stored in the same memory as a normal variable, it is not a huge amount of information that is requested from the disc when needed.

Roughly speaking, a global terminal variable is almost like a file. Otherwise, where is it stored when the computer is switched off? And a global-level variable accessible from any place in the programme is a variable in memory. Naturally, it is faster.

It turns out that at a new opening it is better to write both to the global level variable and to the global variable of the terminal to restore it after the terminal restart. But while the terminal is running, the global level variable should be checked.

 
Alexey Viktorov #:

Roughly speaking, a global terminal variable is almost like a file. Otherwise, where is it stored when the computer is switched off? And a global-level variable accessible from any place of the programme is a variable in memory. Naturally, it is faster.

It turns out that at a new opening it is better to write both to the global level variable and to the global variable of the terminal to restore it after the terminal restart. But while the terminal is running, the global level variable should be checked.

i.e. check the history in OnDeinit and write it to the global terminal variable?

Ideally, there is only a couple of bytes of information in the text form, isn't it contained in the availability as usual variables, i.e. in RAM?

In OnInit we read it, write it to RAM, and then when the variable is updated it is overwritten.

Has anyone actually measured this? Or maybe the developers can help us figure it out.

 
lynxntech #:

I.e. check history in OnDeinit and write to the global Terminal?

Ideally, there is only a couple of bytes worth of information in text form, is it not contained in the availability as normal variables, i.e. in RAM?

In OnInit we read it, write it to RAM, and then when the variable is updated it is overwritten.

Has anyone actually measured this? Or maybe the developers can help us figure it out.

Who said about picking history in OnDeinit()?

I was talking about the necessity to duplicate the variable into the terminal variable at the next position opening...

 
Alexey Viktorov #:

Who said anything about picking history in OnDeinit()?

I was talking about the necessity to duplicate the variable into the terminal variable at the next position opening...

it can all be done, the question was to those who measured the real work, and better to the developers, who knows what they have in their plans.

I don't want to experiment, there are many other tasks.

 

Good evening, dear programmers!

Help me to solve a simple problem. There is a code from MQL4. I want to adapt it to 5. That is, to work similarly in MQL5.


//Введем внешнюю переменную, чтобы иметь возможность изменить количество сканируемых свечей.
extern int Window=30;
 
void OnStart()
{
   //Вводим переменные.
   double Highest=High[0];
   double Lowest=Low[0];
 
   //Сканируем 30 свечей и обновляем значения самых высоких и самых низких цен.
   for(int i=0; i<=Window; i++) {
   if(Low[i]<Lowest) Lowest=Low[i];
   if(High[i]>Highest) Highest=High[i];  
}
 
   //Выводим результат.
   Alert("Самая высокая цена ",Highest," - Самая низкая цена ",Lowest);
}



My variant obviously does not pass, for some reason there are a lot of errors):

//Введем внешнюю переменную, чтобы иметь возможность изменить количество сканируемых свечей.
extern int Window=30;
 
 
void OnStart()
{

double   o = iOpen(NULL, PERIOD_CURRENT, 0);
double   h = iHigh(NULL, PERIOD_CURRENT, 0);
double   l = iLow(NULL, PERIOD_CURRENT, 0);
double   c = iClose(NULL, PERIOD_CURRENT, 0);

double Highest=h;
double Lowest=l;

   //Сканируем 30 свечей и обновляем значения самых высоких и самых низких цен.
     
   for(int i=0; i<=Window; i++) 
{
   if  ( l[i] < Lowest ) 
   Lowest=[i];
  

   if  ( h[i] > Highest ) 
   Highest=[i];  
  
}
 
   //Выводим результат.
   Print("Самая высокая цена ",Highest,
         " - Самая низкая цена ",Lowest);
}
 
Reason: