//lookback 15 bars to find Min and nmin or barmin int look_back_size = 15; int nmin = iLowest(_Symbol, _Period, MODE_CLOSE, look_back_size + 1, i); double min = Close[nmin]; //from i to Min, find Max2 int nmax2 = iHighest(_Symbol, _Period, MODE_CLOSE, nmin - i + 1, i); double max2 = Close[nmax2]; //from i to nMax2, find Min2 and Nmin2------------------------------------------------------------ int nmin2 = iLowest(_Symbol, _Period, MODE_CLOSE, nmax2 - i + 1, i); double min2 = Close[nmin2];On my mind, something like this will be better (sorry, I didn't test the code).
Sergey Dzyublik:
On my mind, something like this will be better (sorry, I didn't test the code).
On my mind, something like this will be better (sorry, I didn't test the code).
Thanks Sergey,
I do a speed test, calculating for 2000 bar.
The original take about 3 second. the new method take about 12 second.
HHC
hhchenfx:
Try with ArrayMinimum() and ArrayMaximum().
Thanks Sergey,
I do a speed test, calculating for 2000 bar.
The original take about 3 second. the new method take about 12 second.
HHC
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
Hi Everyone,
I wrote the below code. The idea is:
From a given bar i (say when MA5 cut MA10), lookback 15 bar, find Min Close bar (call min and nmin)
From bar i to Min Close bar, find Max Close bar (call max2 and nmax2)
From bar i to Max Close bar, find Min Close bar (call min2 and nmin2)
I wrote 3 for() to get it. Yes it works but it take quite long time.
Do I make any logic mistake and if you could tell me if there is a way to make it runs faster?
Thank you,
HHC