
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
You are wrong, send me the original and I will show you. I will not build the indicator from the snippets posted here.
If you are not interested it's ok.
The code of the complete indicator :
It draws this :
The code used in this indicator is different (different, faster, way of preparing and passing array elements but the results are the same) The 2 lines of code that need optimization remain the same (as it is obvious, since, practically, it is all that remains in the function calculation code)
You are wrong, send me the original and I will show you. I will not build the indicator from the snippets posted here.
If you are not interested it's ok.
Hi Alain,
I'm just curious if it's possible to write the part of code (I've marked it in the code) in more efficient way. Therefore I've written my own indicator and I'll be glad if you show me your approach.
Thank you in advance.
The code of the complete indicator :
It draws this :
The code used in this indicator is different (different, faster, way of preparing and passing array elements but the results are the same) The 2 lines of code that need optimization remain the same (as it is obvious, since, practically, it is all that remains in the function calculation code)
Hi Alain,
I'm just curious if it's possible to write the part of code (I've marked it in the code) in more efficient way. Therefore I've written my own indicator and I'll be glad if you show me your approach.
Thank you in advance.
I will work on Mladen code, which is mql5. You will just have to apply it to your code if I succeed ;-)
It's OK. The code is pretty similar. The difference is that I don't use time[] as an axis "x" because time axis is discontinuous in MT (because of e.g. weekends an so on). But I'm sure that I'll be able to understand your MQL5 code.
If you're successful I'll call you "Master of efficiency" ;-)
Good luck.
So at my surprise, I didn't succeed. The main optimization idea I had was to reduce the number of division operations needed :
As this operation is done in a loop for every candle i, there are a lot of repetitions of the exact same operation. So the idea was to do all the operations once and to memorize them (see attached how I did). However it doesn't improve this speed, even while the numbers of operations was reduced by a factor 16 !
From 64 millions to 4 millions division operations, but no change in execution time. I didn't expect that. That means double arithmetic CPU is very efficient and cached very well all the results.
Also, though this imbricated loop with division operations is time consuming, the main bottleneck in the ArraySort(), the speed impact is more than 3 times the one of the loops. So even if the "division" optimization had worked that global impact would have been low (~20% max).
That was an interesting exercise, even if it failed.
Attached the code (as we are on week-end I didn't pay attention to "live" update).
So at my surprise, I didn't succeed. The main optimization idea I had was to reduce the number of division operations needed :
As this operation is done in a loop for every candle i, there are a lot of repetitions of the exact same operation. So the idea was to do all the operations once and to memorize them (see attached how I did). However it doesn't improve this speed, even while the numbers of operations was reduced by a factor 16 !
From 64 millions to 4 millions division operations, but no change in execution time. I didn't expect that. That means double arithmetic CPU is very efficient and cached very well all the results.
Also, though this imbricated loop with division operations is time consuming, the main bottleneck in the ArraySort(), the speed impact is more than 3 times the one of the loops. So even if the "division" optimization had worked that global impact would have been low (~20% max).
That was an interesting exercise, even if it failed.
Attached the code (as we are on week-end I didn't pay attention to "live" update).
Thank you for your effort. Don't be sad I won't call you "Master of efficiency" :D
I really appreciate your approach. Even though you've failed you are still honest (unlike others).
BTW I think that the better approach for OP's needs is using Linear Regression or Kalman filter or something similar.
You don't need to calculate all. Just bars-1. And then find the median for the given period. So, with 129122 bars, calculate 129121 coefficients, and then pick up the median for period. Something like a global coefficient buffer. So coefficients are calculated only at new bars. Is it possible?