int counted_bars=IndicatorCounted(); int limit=Bars-counted_bars;
After the first run, limit will normally be one, and therefor y will be zero. You will never get a fractal with y being zero. In addition your two variables will always be zero.
Don't use the array copy(time) don't count up. Just Write it like normal (How to do your lookbacks correctly) except that it may repaint bars three and down (new fractal,) and then read the values from the other time frame:
int counted_bars=IndicatorCounted(); #define LAST 0 if(tf1 == PERIOD_CURRENT){ #define LOOKBACK MathMax(1, counted_bars) // lookback is [i+1]. #define REPAINT 3 int i=MathMax(REPAINT, Bars - 1 - LOOKBACK); // Repainting indicator on bar 3 for(; i >= LAST; --iBar){ bufup[i] =iFractals( NULL, tf1, MODE_HIGH, i); bufdown[i] =iFractals( NULL, tf1, MODE_LOW, i); if(bufup[i] == 0) bufup[i] = bufup[i+1]; if(bufdown[i] == 0) bufdown[i]= bufdown[i+1]; } } else{ int i=Bars - 1 - LOOKBACK; int iTF = iBarShift(NULL, tf1, Time[i]); datetime tTF = iTime(NULL, tf1, MathMax(REPAINT, iTF) ); // Repainting indicator on tf1 bar 3 string name=WindowExpertName(); for(i=iBarShift(NULL,0, tTF); i >= LAST; --i){ int y = iBarShift(NULL, tf1, Time[i]); bufup[i] =iCustom(NULL, tf1, name, PERIOD_CURRENT, 0, y); bufdown[i]=iCustom(NULL, tf1, name, PERIOD_CURRENT, 1, y); } } return(0);
After the first run, limit will normally be one, and therefor y will be zero. You will never get a fractal with y being zero. In addition your two variables will always be zero.
Don't use the array copy(time) don't count up. Just Write it like normal (How to do your lookbacks correctly) except that it may repaint bars three and down (new fractal,) and then read the values from the other time frame:
whrieder1,
Thank you very much for your response. I am trying to understand the code (I am still novice in coding).
I have attempted to compile using above coding. But got 2 errors.
Error 1) iBar not defined
int i=MathMax(REPAINT, Bars - 1 - LOOKBACK); // Repainting indicator on bar 3 for(; i >= LAST; --iBar){
If I understood correctly, below iBar is i instead of iBar.
Error 2)
else{ int i=Bars - 1 - LOOKBACK;
int i already defined -> just delete int.
I have compiled and seems working fine at least for the first sight, Please let me know if I am mistaken.
Belanda
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello.
I use this Support & Resisitance Line indicator.
There is no issue when applied initially or after switching to another timeframe and come back to original timeframe.
However, the lines are not updated even after corresponding higher timeframe candles which factors fractals are closed.
Can skilled coder take a look and point out coding error?
Belanda