Performance issue in backtesting with ifractal

 

Hello all.

I did some research before posting about the correct use of iFractal

I am using this function to get the most recent swing high swing low into a routine with a very simple code

double getLastHigh() {

double high;

high = iFractals(Symbol(), PERIOD_M5, MODE_UPPER, 3);
if (high > 0) {
return (high);
}

return (0);
}

double getLastLow() {

double low;

low = iFractals(Symbol(), PERIOD_M5, MODE_LOWER, 3);
if (low > 0) {
return (low);
}

return (0);
}

Since I introduced into the code the two functions, when I run in visual mode MT4 I can notice that the code affects the speed of strategy tester.

Do you think that is just something about the visualization and I can use this code with no problems or should I write two new functions to calculate the fractals ?

Thanks in advance, Francesco.

 

Before posting please read some of the other threads . . . then you would have seen numerous requests like this one:

Please use this to post code . . . it makes it easier to read.

 
zen4x:


Since I introduced into the code the two functions, when I run in visual mode MT4 I can notice that the code affects the speed of strategy tester.

Do you think that is just something about the visualization and I can use this code with no problems or should I write two new functions to calculate the fractals ?

Thanks in advance, Francesco.

Maybe iFractal takes a lot of processing . . . it would explain why the ST slows down . . do you run it for ever tick or just when a new bar occurs ?
 

Hi Zen4x

If by visualisation you mean the strategy tester is running every tick on the chart in front of you then it will run slow. Uncheck the visual mode box and see the true speed. The visual mode is only meant for viewing particular trades not the whole time range of a backtest.

 
RaptorUK:

Before posting please read some of the other threads . . . then you would have seen numerous requests like this one:

Please use this to post code . . . it makes it easier to read.


I will Raptor, I won't forget next time I need to past code.

Thank you for the support, I appreciated

 
RaptorUK:

Before posting please read some of the other threads . . . then you would have seen numerous requests like this one:

Please use this to post code . . . it makes it easier to read.

Thanks Raptor for the support
 
zen4x:

Hello all.

I did some research before posting about the correct use of iFractal

I am using this function to get the most recent swing high swing low into a routine with a very simple code

double getLastHigh() {

double high;

high = iFractals(Symbol(), PERIOD_M5, MODE_UPPER, 3);
if (high > 0) {
return (high);
}

return (0);
}

double getLastLow() {

double low;

low = iFractals(Symbol(), PERIOD_M5, MODE_LOWER, 3);
if (low > 0) {
return (low);
}

return (0);
}

Since I introduced into the code the two functions, when I run in visual mode MT4 I can notice that the code affects the speed of strategy tester.

Do you think that is just something about the visualization and I can use this code with no problems or should I write two new functions to calculate the fractals ?

Thanks in advance, Francesco.



Hi zen

I was working on learning this exact topic a while back myself and these guru's helped me understand ifractals a great deal better

See this huge long post from the beginning here
https://www.mql5.com/en/forum/135824/page8

Short story is I went down the road to see someone's indicator which marks the ifactal high/lows with lines or dots on the charts but could not figure out how to actually select or use data from a particular ifractal
So as it turned out I didn't really want to make an indicator but thought I could learn from this code to help me make and EA

Anyhow from your code it looks like you need to do the same thing, using an incrementing loop to select the last high / low. Especially if new low has formed how do you select and use the ifractal high that came before it and determine if it is the high that came before the low or a new high forming after the previous low (a paradox sort of ) at least is was for me.
But thanks to the guru's on the forums I do understand a lot of this now.

Although that codeI made is using A and B as a previous high/low and excluding them when new ifractal forms in between both of those A/B levels which then becomes my C level I think you can use this to help you with your code and understanding how to refer to the current high / low of the iFractals

Hope this helps

Happy Coding

Reason: