A question for MQL connoisseurs

 
Good day to all!
My question is as follows: how can I make an indicator recalculate itself no more often than a certain number of times per second, for example no more than 2 times.
The Sleep function does not work in indicators.
 
Debugger писал(а) >>
Good day to all!
My question is: how can I make an indicator recalculate itself no more often than a certain number of times per second, for example no more than 2 times.
The Sleep function does not work in indicators.


Why?
 
The algorithm takes a long time to calculate.
 
Debugger писал(а) >>
The algorithm takes a long time to calculate.


Maybe you should optimise the algorithm first. Although once every second, or every 10 seconds calculation can be done.
We save the last calculation time.
On next ticks, we check the number of seconds that have passed.
If it is more than the specified time, it is calculated, otherwise we exit without calculation
 
You can measure between ticks in milliseconds with this:
int GetTickCount();
// Функция GetTickCount() возвращает количество миллисекунд, прошедших с момента старта системы.
// Счетчик ограничен разрешающей способностью системного таймера. Так как время хранится как беззнаковое целое, то он переполняется каждые 49.7 дней. 
 
Vadim, you've helped me out again. Huge respect!!!!
 
Hello, could you please review the code and explain why this indicator lags for brokerage companies that give 5 digits quotes and works fine for brokerage companies that give 4 digits quotes. I wonder if it can be corrected in some way to make it work with brokerage companies with 5 digits. If you have any doubts, please do not hesitate to contact your brokerage company.
Files:
 

Yes, indeed. At the 5 digit mark, the turkey is slowing down.

I don't know why. It's all right in the code...

 
rid >>:

Да, действительно. На 5-ти знаке индюк тормозит.

А вот почему, не пойму. Вроде всё норм. в коде...

Probably the frequency of quotes is higher than on 4.

Compare tick volumes.

----- and recalculation and re-rating should be done when there is a "significant" change in price.

"Materiality" should probably be put in the parameters. 5-7 pips on a 5 marker won't change the weather.

;)

 
FreeLance >>:

Наверно частота котировок выше чем на 4-х.

Сравните тиковые объемы.

If so, the calculation can be done on every 3rd or 5th tick at 5 digits.

Or generally by the bars formed.

 

Good afternoon.

There is an indicator in the Code Base section - https://www.mql5.com/ru/code/8752.

According to the description, it shows on the history in its window the equity of one position or the sum of several positions. On a certain period of history.

I cannot run it even for one currency!

"Before you install the indicator, create at least one vertical line on the chart with the following parameters:
The position of the line openN (where N is the ordinal number of the packet) sets the time of the packet opening
."

I have created a vertical line. But I don't understand - what is the parameter openN (it is not present in Properties) and where N is set ?

Further :

"The positions in the indicator are only set with trend lines of a certain colour on the instrument chart.
The position of the line determines the opening and closing time of the packet."

I don't know how to draw a limited segment of the trend line. It appears to be an endless ray in one direction all the time.

Please advise.

Reason: