Just a common question; I'm sure most gurus would find is child's play.
If I wanted to find 50% of 1000 (Which I know outside of coding is 500), how would I employ coding to process this answer?
double pct = 1000 * 0.5;
If you care about accuracy, use double. If you don't care for the decimal point, use int. Alternatively, you can use int and round / round up / round down before assigning it to the pct variable. Just make sure you typecast to int so the compiler doesn't give you a warning.
int pct = (int) MathRound(1000 * 0.5);

- docs.mql4.com
Just a common question; I'm sure most gurus would find is child's play.
If I wanted to find 50% of 1000 (Which I know outside of coding is 500), how would I employ coding to process this answer?
Be careful about making divisions between integers.
Just multiply 0.5 (which's 50%) * 1000 (supposed to be the balance?).
The 1000 was just a random number I extracted from the mql4 tutorial documentation regarding problem 16 I understand what you're saying, and both answers to the question are correct methods of course.
Since there is no direct percent standard function, I believe that there is some kind of code formula one can conjure that'll always output the percent of any number... ( I'll figure it out).

- book.mql4.com

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Just a common question; I'm sure most gurus would find is child's play.
If I wanted to find 50% of 1000 (Which I know outside of coding is 500), how would I employ coding to process this answer?