I have questions regarding 2 specific code, Any help is greatly appreciated.
1: NormalizeDouble ---> is it possible for this command to return the value ZERO?
2. If I specify a external value and then change the value inside the script would the new value remain or would it reset to the external value everytime it runs?
example:
extern int ABC = 1.111;
int start()
{
..............
if(x>y){ ABC = 0;}
........
}
In this case, would ABC remain 0 the next time the EA runs itself or would it revert back to 1.111? Thanks!
1) Yes
double val = 0.1; double normVal = NormalizeDouble(val, 0); // = 02) It wouldnt be changed as long as your EA is running
What about
double val = 0.03;
double normVal = NormalizeDouble(val,1);
Would that also return zero? I am trying to not get zero and hoping it would round up to 0.1.
2) Are you saying ABC would remain 1.111?
NormalizeDouble(val,1);
digits | - | Precision format, number of digits after decimal point (0-8). |
it only rounds up by inspection of the (digits+1)'th digit and if >=5 rounds the digits'th position (which of course can cause further digits to it's left to get bumped up to)
IF ",1" THEN 0.03 > 0.0; why? cuz 0 is in the digits position and the (digits+1)'th digit <5 causing the digits'th position to NOT round up
IF ",1" THEN 0.05 > 0.1; why? cuz the (digits+1)'th digit >=5 causing the digits'th position rounds up
eg:
Print(NormalizeDouble(0.05,1)); //2008.12.01 11:30:24 test USDCAD,M15: 0.1
and:
Print(NormalizeDouble(0.059,1)); //2008.12.01 11:32:42 test USDCAD,M15: 0.1
see how 9 did not influence rounding?
.
"2) Are you saying ABC would remain 1.111?"
as long as EA attached to chart ABC stays at the last value code assigned to it.
when EA is attached to chart, ABC has initialized value of 1.111 and remains this until/if code assigns new value.
.
"the next time the EA runs itself "
EA not run itself, Terminal does. start() keeps getting called if not already running that is, for each new incoming data tick.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I have questions regarding 2 specific code, Any help is greatly appreciated.
1: NormalizeDouble ---> is it possible for this command to return the value ZERO?
2. If I specify a external value and then change the value inside the script would the new value remain or would it reset to the external value everytime it runs?
example:
extern int ABC = 1.111;
int start()
{ ..............
if(x>y){ ABC = 0;}
........ }
In this case, would ABC remain 0 the next time the EA runs itself or would it revert back to 1.111? Thanks!