Percent Shows Only Zero 8-) Still Trying To Learn MQL
Files:
mtf_ma_comment.mq4
4 kb
Hi Subgenius,
Declare 'em as double
double S=0.0, B=0.0;
Is type casting thing (https://docs.mql4.com/basis/types/casting). Integer takes 4 bytes, while double takes 8 bytes.
:D
Percent = ((S/9)*100
int/int = int. 2/9=0 not .2222.
RTFM Type casting - MQL4 Documentation
Use this and you would have found Operations and Expressions - Basics of MQL4 - MQL4 Tutorial and Why does 4/6 = 0 - MQL4 forum
- Either change B,S to double or
- Use (S/9.0) or
- use Double(S)/9*100
int Int(int a){ return(a); } double Double(double a){ return(a); }