Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1283

 
MakarFX:

How do I determine how much load an EA puts on the server?

At every tick it asks Ask, Bid, Spread, TICKVALUE

If I understand correctly, the profiler will help. But we should understand that the load is not the same as the load. It is time spent on request execution and CPU load. If there is one Expert Advisor per symbol on one window, it's OK. But if there are 120 windows at 40 symbols and so in 10 terminals in one machine, the machine might freeze.)

 
Aleksei Stepanenko:

I don't know, you could try it in battle. Or perhaps as an optionINT_MAX?


Yes, that's how I calculate:

And from date to date including weekends is something else.

Points per second, yes it's readable. And on lower TFs the speeds are higher and the range is smaller.

_     ;qstr7_41;_;EURUSD;_TF_;1; Имя файла ;QstrV.csv; Локальное время ;2020.10.23 15:34:25
2020.10.23 14:34:20; [i]= ;13; VTrend[i] = ;25; SumVTrend= ;97; AbsVTrend= ;341; pos= ;8;SumVTrendPos= ;339; neg= ;7; SumVTrendNeg= ;-345
2020.10.23 14:34:20; [i]= ;2; VTrend1[i] = ;272; SumVTrend1= ;17; AbsVTrend1= ;137; pos1= ;2;SumVTrendPos1= ;-84; neg1= ;2; SumVTrendNeg1= ;-84
_     ;qstr7_41;_;EURUSD;_TF_;5; Имя файла ;QstrV.csv; Локальное время ;2020.10.23 15:34:36;
 2020.10.23 14:34:31; [i]= ;15; VTrend[i] = ;414; SumVTrend= ;47; AbsVTrend= ;124; pos= ;9;SumVTrendPos= ;160; neg= ;8; SumVTrendNeg= ;-82
2020.10.23 14:34:31; [i]= ;2; VTrend1[i] = ;-32; SumVTrend1= ;63; AbsVTrend1= ;83; pos1= ;2;SumVTrendPos1= ;37; neg1= ;2; SumVTrendNeg1= ;-32
_     ;qstr7_41;_;EURUSD;_TF_;1440; Имя файла ;QstrV.csv; Локальное время ;2020.10.26 15:42:42;
2020.10.26 14:42:42; [i]= ;14; VTrend[i] = ;-26; SumVTrend= ;3; AbsVTrend= ;9; pos= ;9;SumVTrendPos= ;9; neg= ;7; SumVTrendNeg= ;-11
2020.10.26 14:42:42; [i]= ;1; VTrend1[i] = ;-7; SumVTrend1= ;-7; AbsVTrend1= ;7; pos1= ;1;SumVTrendPos1= ;0; neg1= ;2; SumVTrendNeg1= ;-7
 
Valeriy Yastremskiy:

If I understand correctly, a profiler will help. But you have to understand that load is not the same as load. This is time spent on query execution or CPU load on the machine. If there is one Expert Advisor per symbol on one window, it's OK. And if there are 120 windows at 40 symbols and so in 10 terminals in one machine, the machine might freeze.)

We have already discussed if the terminal data from MQL4 should be accessed many times, then OrderSelecthttps://www.mql5.com/ru/forum/342989#comment_16743716

the same way you can test getting the current price - I think you can use it 100500 times per tick as well, since the output will be increased millions of times per second


the more symbols in the market watch window, the bigger will be load on the terminal itself, and respectively, if you call data from a lot of different symbols, then you will also get lags

i.e. if you use the terminal sensibly, nothing will freeze - in the market watch window there are ten symbols you use


i haven't checked how many charts you can open at the same time, but i think that if you limit the history to 1000 bars, then i think the terminal will probably open a couple dozen chart windows without any problems

 

Good day to all!

I have started to study mql5 (after mql4). There is a function group in mql4 called date and time. There is the same group in five. But this group of functions in five is much less than in four. There are no functions in five that return values of the current hour, minute ... and other functions.
For example, in fourth there was the Hour() function, which returned the value of the current hour. Five has no such function.
QUESTION

Which functions in five are analogous to Hour() and other functions from the four's Date and Time function group that are not in the similar group in five.

Thank you for your help.

 
Igor Makanu:

We have already discussed whether it is necessary to repeatedly access terminal data from MQL4, then OrderSelecthttps://www.mql5.com/ru/forum/342989#comment_16743716

i think it is possible to use it 100500 times per tick as well, because the output will be increased millions of times per second


the more symbols in the market watch window, the bigger will be load on the terminal itself, and respectively, if you call data from a lot of different symbols, then you will also get lags

i.e. if you use the terminal sensibly, nothing will freeze - in the market watch window there are ten symbols you use


i haven't checked how many charts you can open at the same time, but i think that if you limit the history to 1000 bars, then the terminal will probably open a couple dozen chart windows without any problems

(Thank you for the reminder))) I mean that with reasonable requests everything should work, i.e. low-cost (in terms of time of execution and CPU load) requests).

 
ANDREY:

Good day to all!

I have started to study mql5 (after mql4). There is a function group in mql4 called date and time. There is the same group in five. But this group of functions in five is much less than in four. There are no functions in five that return values of the current hour, minute ... and other functions.
For example, in fourth there was the Hour() function, which returned the value of the current hour. Five has no such function.
QUESTION

Which functions in five are analogous to Hour() and other functions from the date and time function group in four that are not in the similar group in five.

Thank you for your help.

use https://www.mql5.com/ru/docs/dateandtime/timecurrent

second version of the function call

datetime  TimeCurrent(
   MqlDateTime&  dt_struct      // переменная типа структуры
   );
in general, it ishttps://www.mql5.com/ru/docs/dateandtime/timetostruct
 
A tip for a 4k. How to return mouse click coordinates on the chart, preferably by bar number. I can only find the coordinates where the script was thrown.
 
Valeriy Yastremskiy:

Thanks, that reminds me))) Yes, a lot of things I didn't understand at the time) I just wanted to say that with reasonable requests everything should work. These are cheap in cost (execution time and CPU load) requests).

yes

If the code is "dirty", you can screw up any system

and if it is a reasonable use, where reference to the Ask/Bid price occurs even a few tens of times per tick, then it will not affect the EA performance (maximum 1-2%)

i.e. the logic of using resources (or calls of system functions / environment of the terminal) should be, if the algorithm implies accessing Ask/Bid prices several thousand times per tick, then.... most likely you should reconsider the algorithm itself, or alternatively, remember the values ofAsk/Bid once before calculating the algorithm




Valeriy Yastremskiy:
Please advise for 4k. Coordinates of mouse click on a chart how to return, preferably by a bar number. Find only the coordinates where they threw the script.

probably look forChartXYToTimePrice https://docs.mql4.com/ru/chart_operations/chartxytotimeprice

only discussedhttps://www.mql5.com/ru/forum/353726

here's another thread also discussing clickshttps://www.mql5.com/ru/forum/344607

 
Igor Makanu:

if the algorithm implies referring to Ask/Bid prices several thousand times per tick, then.... most likely you should reconsider the algorithm itself, or alternatively, remember Ask/Bid values once before calculating the algorithm




perhaps look forChartXYToTimePrice https://docs.mql4.com/ru/chart_operations/chartxytotimeprice

just discussedhttps://www.mql5.com/ru/forum/353726

here's another thread also discussing clickshttps://www.mql5.com/ru/forum/344607

In general, if we got prices on the tick, we can work with them until the end of OnTick, if it's not critical. And limiters to help prevent slippage).

I wanted to click on a candlestick and write its value into a file.

CHARTEVENT_MOUSE_MOVE

 
Valeriy Yastremskiy:

Generally, if we got prices on the tick, we can work with them until the end of the OnTick, if not critical. And limiters to help against slippage)

I want to click on a candle and save its value in a file.

CHARTEVENT_MOUSE_MOVE

Maybe that's how you want to determine the bar price and time:

void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
{
   if(id == CHARTEVENT_CLICK)
   {
      int window = 0;
      datetime time;
      double   price;
      if(ChartXYToTimePrice(0, (int)lparam, (int)dparam, window, time, price))
      {
         Print("time = ", time, " ,price = ", price);
      }
   }
}
or rather these are mouse click coordinates in the values time + price on the chart, the bar should be defined viaiBarShift()