hi, i recoded the iFractal(), iOpen(), iClose(), iHigh(), iLow() functions. and replaced the original function calls.
but the indi doesn't behave 100% like the original ... and it still doesn't run in the strategy tester.
any ideas why?
here the modified indi:
Files:
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, i work in converting the MTF_Resistance-Support (https://www.mql5.com/en/code/10063) indicator so that it works in the strategytester.
i modified the indicator to show the breakouts through the lines.
the indicator uses multiple timeframes and the iFractals() function to calculate the resistance and support lines.
i see the iFractals() function as the issue that has to be reprogrammed, that it just use the current timeframe data of the strategytester window, is that right?
here the main calculation in the indicator, to calculate the different timeframes stored in per[], it uses iFractals():
datetime time = iTime(NULL,Period(),i);
shift[a]=iBarShift(NULL,per[a],time,true);
mabel1 = iFractals(NULL, per[a], MODE_UPPER,shift[a]);
mabel2 = iFractals(NULL, per[a], MODE_LOWER,shift[a]);
I've tried to calculate iFractals from the data of the current chart, so i wrote these functions:
double uFractal_tf (int tf, int mode, int shift)
{
datetime time = iTime(NULL,Period(),shift);
int i=iBarShift(NULL,tf,time,true);
time = iTime(NULL,tf,i);
i=iBarShift(NULL,Period(),time,true);
int bars;
if (tf<Period()) bars=Period()/tf; else bars=tf/Period();
if (mode==MODE_UPPER)
return (uFractal_upper (bars, i));
if (mode==MODE_LOWER)
return(uFractal_lower (bars, i));
return(0);
}
// ---------------------
double uFractal_upper (int bars, int shift)
{
if (shift-bars*2<0) return(0);
double tmp1 = uHigh(bars,shift+bars*2);
double tmp2 = uHigh(bars,shift+bars*1);
double tmp3 = uHigh(bars,shift);
double tmp4 = uHigh(bars,shift-bars*1);
double tmp5 = uHigh(bars,shift-bars*2);
if (tmp1<=tmp3 && tmp2<=tmp3 && tmp4<=tmp3 && tmp5<=tmp3) return(tmp3); else return(0);
}
// ---------------------
{
if (shift-bars*2<0) return(0);
double tmp1 = uLow(bars,shift+bars*2);
double tmp2 = uLow(bars,shift+bars*1);
double tmp3 = uLow(bars,shift);
double tmp4 = uLow(bars,shift-bars*1);
double tmp5 = uLow(bars,shift-bars*2);
if (tmp1>=tmp3 && tmp2>=tmp3 && tmp4>=tmp3 && tmp5>=tmp3) return(tmp3); else return(0);
}
// ---------------------
{
double tmp=0;
for (int i=shift; i>shift-bars; i--)
if (tmp<High[i]) tmp=High[i];
return(tmp);
}
// ---------------------
{
double tmp=0;
for (int i=shift; i>shift-bars; i--)
if (tmp==0 || tmp>Low[i]) tmp=Low[i];
return(tmp);
}
so i changed the main calculation to this:
datetime time = iTime(NULL,Period(),i);
shift[a]=iBarShift(NULL,per[a],time,true);
//mabel1 = iFractals(NULL, per[a], MODE_UPPER,shift[a]);
//mabel2 = iFractals(NULL, per[a], MODE_LOWER,shift[a]);
mabel1 = uFractal_tf (per[a], MODE_UPPER, i);
mabel2 = uFractal_tf (per[a], MODE_LOWER, i);
It works in a way... but not properly, might there be a bug in it?
or have i forgot to look at something else?
what do you mean? i actually don't see a bug..
can you help me?
regards,mally
I'll attach the original code and the modified code files:
* mtf-resistance-support_edit01_byuwe.mq4 // is the original source
* mtf-resistance-support_edit01-1_byuwe.mq4 // is the modified source