It is possible that the ProfitToday() function returns a different result when called again.
Call it only 1 time. To do this, save the result to a variable.
whoowl: The Print log says: Exceeded. ProfitToday is: -1.14 MaxLoss -10. I am confused. I thought -1.14 was > -10. But the condition is <= and it's triggering. I changed the condition to > and it's not triggered anymore, but I can't leave it that way because I can't understand what is really going on. What am I doing wrong? Isn't -1.4 greater than -10?
As a "good practice" in programming, functions should not be called more than once when referring to their returned value multiple times.
For one, it is inefficient if the function has to process the data yet again, and for the other, the returned value may be different on subsequent calls just as @Vladislav Boyko has suggested.
Always assign the function's return value to a local variable and then use that variable subsequently.
// Uncompiled, untested, just typed out as an example double dbProfitToday = ProfitToday(); if( dbProfitToday <= MaxLoss ) Print( "Exceeded ProfitToday is: ", dbProfitToday, " MaxLoss ", MaxLoss );
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The Print log says:
Exceeded. ProfitToday is: -1.14 MaxLoss -10
I am confused. I thought -1.14 was > -10. But the condition is <= and it's triggering.
I changed the condition to > and it's not triggered anymore, but I can't leave it that way because I can't understand what is really going on.
What am I doing wrong? Isn't -1.4 greater than -10?