Dmitry Fedoseev: I don't know. If everything is slow to start with, maybe 10 ifs won't make a difference. But I already notice it on the third one. So the need for each new ife is carefully weighed.
There are only two reasons for the slowdown, the first is that the condition in the if statement is constructed incorrectly and the second is that after the if statement is triggered the further execution is written incorrectly inside the body.
I have a bar analyzer, there are much more than 3 if's with internal if's, it goes through all the bars and their values, fixes the sum and writes in the window that opens, all in a fraction of a second.
So the lags are not because of if but because of its incorrect use.
There are only two reasons for the slowdown, the first is that the condition in the if statement is constructed incorrectly and the second is that after the if statement is triggered the further execution is written incorrectly inside the body.
I have a bar analyzer, there are much more than 3 if's with internal if's, it goes through all the bars and their values, fixes the sum and writes in the window that opens, all in a fraction of a second.
So, the slowdown is not because of if, but because it is used incorrectly.
What are you arguing with? That two ifs work twice as slow as one if? And three ifs are three times slower than one?
Alexey Busygin: If an if doesn't work, it means that its conditions are
What I wanted to say is this: I have some rather heavy calculations. I usually do this to speed things up: I put the easiest calculations in if conditions, and hide the heavy code in its body.
If easy ones don't work, then the hard ones won't be checked at all.
What I wanted to say is this: I have some rather heavy calculations. I usually do this to speed things up: I put the easiest calculations in if conditions, and hide the heavy code in its body.
If light ones don't work, then the heavy ones are not checked at all.
What do you mean by heavy calculations? An example of light and heavy calculations is possible!
Alexey Busygin: What do you mean by heavy calculations? An example could be light and heavy!
Well, here's an example. There is a relatively light two-slide indicator and a heavy indicator. The "heavy" calculations are resource-intensive.
if (ma7_2 < ma15_2 && ma7_1 > ma15_1)//пересечение короткой скользящей вверх
{
indikator=iCustom(NULL,0,"TSI",p2,p3,p4,p5,0,1);//тяжелый для вычисления индикатор//сюда можно вставить и кучу другого кода, если мувинги не пересеклись, то и последующих вычислений не будет
}
Well, here's an example. There is a relatively light two-slide indicator and a heavy indicator. The "heavy" calculations are resource-intensive.
So what's the heavy calculations? Nothing! I've had cases when there was"for(){for(){for(){for(){}}}" in the if triple forte and nothing, no complaints, I called it and it counted.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
Guys, I'm not good at this yet, how do I fill in the lines?
double sto1=(bar close price);
double sto2=(open price of the new bar) ;
iClose(NULL,0,1)
iOpen(NULL,0,0)
Read about these functions in the help
I don't know. If everything is slow to start with, maybe 10 ifs won't make a difference. But I already notice it on the third one. So the need for each new ife is carefully weighed.
There are only two reasons for the slowdown, the first is that the condition in the if statement is constructed incorrectly and the second is that after the if statement is triggered the further execution is written incorrectly inside the body.
I have a bar analyzer, there are much more than 3 if's with internal if's, it goes through all the bars and their values, fixes the sum and writes in the window that opens, all in a fraction of a second.
So the lags are not because of if but because of its incorrect use.
iClose(NULL,0,1)
iOpen(NULL,0,0)
Read about these functions in the help
There are only two reasons for the slowdown, the first is that the condition in the if statement is constructed incorrectly and the second is that after the if statement is triggered the further execution is written incorrectly inside the body.
I have a bar analyzer, there are much more than 3 if's with internal if's, it goes through all the bars and their values, fixes the sum and writes in the window that opens, all in a fraction of a second.
So, the slowdown is not because of if, but because it is used incorrectly.
What are you arguing with? That two ifs are twice as slow as one if? And three ifs are three times slower than one?
What about when explicitly "heavy code" is placed in the if body? If an if doesn't work, what's inside it doesn't count.
If an if doesn't work, it means that its conditions are
What I wanted to say is this: I have some rather heavy calculations. I usually do this to speed things up: I put the easiest calculations in if conditions, and hide the heavy code in its body.
If easy ones don't work, then the hard ones won't be checked at all.
What I wanted to say is this: I have some rather heavy calculations. I usually do this to speed things up: I put the easiest calculations in if conditions, and hide the heavy code in its body.
If light ones don't work, then the heavy ones are not checked at all.
What do you mean by heavy calculations? An example could be light and heavy!
Well, here's an example. There is a relatively light two-slide indicator and a heavy indicator. The "heavy" calculations are resource-intensive.
Well, here's an example. There is a relatively light two-slide indicator and a heavy indicator. The "heavy" calculations are resource-intensive.