Re: MT5 Channel type indicators

21
From Mladen Rakic:

In TA some functions are, sometimes, overestimated and some are sometimes, underestimated
One of the usually underestimated is the the function used for calculating minimum or maximum of some data sample

* almost all functions that I saw that do that are some kind of a sorting functions offspring
* that is the case with the built in metatrader functions too
* and even though there are excellent sorting algorithms it is often forgotten that minimum and maximum calculation is not about sorting some data (at all)


So went on a search spree for better ways to calculate it. There are some solutions and attaching an original paper published by Daniel Lemire in 2008 (it is a public document downloaded from here : https://r-libre.teluq.ca/207/1/webmaximinalgo.pdf) . In it you can find a pseudo code for how he solved. But, for time series data in trading terminal(s), that algorithm might cause errors in some cases (partial data reload, just one example). Hence, I made what could be called rolling minimum-maximum that does not suffer from that kind of issues (and is even faster due to different way how memory is allocated and used).

One might wonder what it (the minimum-maximum) is used for. And frankly, probably in majority of indicators used there is some sort of it used. Attaching just one simplest way of looking for trend via simple minimum and maximum
_________________________
All the parameters as usual except for one :

* displaying the execution time or not
* it shows the execution time for the full set of historical bars only
* displaying the execution time for last tick only would not serve any purpose (since, for example, for 5000 bars execution time is usually 3-400 microseconds on an average CPU. ie: it takes less than a microsecond for just one bar on a last tick - it would display 0 most of the time)
* left it simply as a caprice to be able to check in details how the execution times are almost not varying at all when you start using long(er) periods (unlike when you do that with built in functions)

The rest is fairly simple to see what it does and how it can be used as any other trend calculating indicator
These users thanked the author mrtools for the post (total 6):
TransparentTrader, 太虚一毫, RodrigoRT7, thomdel, kvak, josi


Re: MT5 Channel type indicators

23
mrtools wrote: Tue Feb 06, 2024 1:17 pm From Mladen Rakic:

In TA some functions are, sometimes, overestimated and some are sometimes, underestimated
One of the usually underestimated is the the function used for calculating minimum or maximum of some data sample

* almost all functions that I saw that do that are some kind of a sorting functions offspring
* that is the case with the built in metatrader functions too
* and even though there are excellent sorting algorithms it is often forgotten that minimum and maximum calculation is not about sorting some data (at all)


So went on a search spree for better ways to calculate it. There are some solutions and attaching an original paper published by Daniel Lemire in 2008 (it is a public document downloaded from here : https://r-libre.teluq.ca/207/1/webmaximinalgo.pdf) . In it you can find a pseudo code for how he solved. But, for time series data in trading terminal(s), that algorithm might cause errors in some cases (partial data reload, just one example). Hence, I made what could be called rolling minimum-maximum that does not suffer from that kind of issues (and is even faster due to different way how memory is allocated and used).

One might wonder what it (the minimum-maximum) is used for. And frankly, probably in majority of indicators used there is some sort of it used. Attaching just one simplest way of looking for trend via simple minimum and maximum
_________________________
All the parameters as usual except for one :

* displaying the execution time or not
* it shows the execution time for the full set of historical bars only
* displaying the execution time for last tick only would not serve any purpose (since, for example, for 5000 bars execution time is usually 3-400 microseconds on an average CPU. ie: it takes less than a microsecond for just one bar on a last tick - it would display 0 most of the time)
* left it simply as a caprice to be able to check in details how the execution times are almost not varying at all when you start using long(er) periods (unlike when you do that with built in functions)

The rest is fairly simple to see what it does and how it can be used as any other trend calculating indicator
so it's just an cpu friendly optimized way to compute the maximum and minimum ?


Who is online

Users browsing this forum: No registered users and 2 guests