Questions from Beginners MQL5 MT5 MetaTrader 5 - page 588

 
barudkinarseniy:

Hello, could you please tell me if it is possible for the Expert Advisor to add an object such as a button or toggle switch to the chart, and if so, how?

Help for objects: OBJ_BUTTON orOBJ_BITMAP. There are examples there.
 
The tester says continuous loss of 3, but I manually counted 5, then more. What could be causing this?
 

edutak:
Тестер пишет, непрерывный проигрыш 3, а я вручную насчитал 5, потом еше больше. Из-за чего такое может быть?

without at least a report from the tester, you can't understand

 
Vladislav Andruschenko:

without at least a report from the tester, you can't understand

 
edutak:

lot 0.1

Could the tester be lying?

 
edutak:
the report is StrategyTester report html
 
Vladislav Andruschenko:
the report is StrategyTester report html
Can't attach it...
 
edutak:
Can't attach...
Archive it.
 
Alexey Viktorov:
Archive it.
Here.
Files:
 



When checking the indicator step by step, I found a bounce in the subroutine behind the if {} and in which there is no W. Here is a simplified code to clarify the point:

//--- input parameters

input int w=10;

//---

{

int i;

//---

int co=0;

for(i=0;i<=w;i++)if(w==10){co++; Alert(co);}

//--- return value of prev_calculated for next call

return(rates_total);

}

Result (arlet):

2016.05.30 00:45:14.064 1 (EURUSD,H1) 11

2016.05.30 01:10:35.972 1 (EURUSD,H1) 10

........... etc. to 1.

2016.05.30 00:45:14.064 1 (EURUSD,H1) 1

Rule: If the expression in brackets is true, then operator1 is executed.

In code: operator1 is executed ALWAYS.

I think if() should work only once when the bracketed condition is true. But it actually occurs at each check, so all expressions in {} are executed at each step and chew machine time.

Questions: WHY did the CO variable grow from 0 to 11 during the loop? Why is Alert triggered at every step?

Files:
1.ex5  7 kb
1.mq5  2 kb
Reason: