Help! - page 4

 
Anton Tarasov:

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

 
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.

 
Dmitry Fedoseev:

iClose(NULL,0,1)

iOpen(NULL,0,0)

Read about these functions in the help

Many thanks Dimitri!
 
Alexey Busygin:

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?
 
Dmitry Fedoseev:
What are you arguing with? That two ifs are twice as slow as one if? And three ifs are three times slower than one?
And 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.
 
forexman77:
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 does not work, then the conditions are
 
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.

 
forexman77:

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);//тяжелый для вычисления индикатор
//сюда можно вставить и кучу другого кода, если мувинги не пересеклись, то и последующих вычислений не будет
}
 
forexman77:

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.