.roman.: p.s. I've tried to zeroize buffers using the SetIndexEmptyValue() but nothing's changed. |
|
Thank you for hints. There's no need to recalculate everything. Added this code and it works ok so far.
for(int b=0;b<=Bars;b++) { if(ExtUpFractalsBuffer[b] && High[0]>ExtUpFractalsBuffer[b]) { ExtUpFractalsBuffer[b]=0.0; SetIndexEmptyValue(0,0.0); } }
But not everything looks that simple.
While loading bars from history(by manual dragging chart to the left) the indicator starts to "shift" the fractals and the charts looks like that. The same problems stays but the fractals are moved in the opposite direction when a certain timeframe of an instrument that has not been loaded for a while is opened). It affects as well the initial idea to display on chart only "non-crossed by price" fractals as far as the old one calculated values are not recalculated when new bars are loaded. How could that be fixed in code?
The problem stays and there appeared another one. When having the indi
on many charts and trying to load low TFs it takes quite a long time and
in case of opening m1-m5 may take minutes. I was trying to optimize it
because I don't need really to know the number of higherhighs, I just need to stop the iteration and to calculate next i. I know that to stop the cycle I need to put break in it (when the terms missmatch) but my brain already gave up on possible solutions, I have no more ideas.
P.S. the only way to get rid of useless iterations that came into my head was to put in the for() the condition of higherhighs to be equal to 0. But still looks ugly though and with break operator may be better.
if(dCurrent>High[i+1] && dCurrent>High[i+2] && dCurrent>High[i-1] && dCurrent>High[i-2]) { int higherhighs=0; for(int h=i;higherhighs==0 && h>=0;h--)

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
that's the part, for example. The idea is to recalculate all the values when the last fractal is "broken". I can't make it work automatically though while manual recompile and re-attaching it works ok of course. So how could the recalculation of buffers be launched after that event?
p.s. I've tried to zeroize buffers using the SetIndexEmptyValue() but nothing's changed.