hknight:
How would you do it manually with a piece of paper and a pencil ?
How can I count the number of items in an array that have the value of "USDCHF"?
hknight: How can I count the number of items in an array that have the value of "USDCHF"?
string xyz[99]; xyz[0] = "USDCAD"; xyz[1] = "USDCHF"; xyz[2] = "EURUSD"; xyz[3] = "USDJPY"; xyz[4] = "AUDUSD"; xyz[5] = "USDCHF"; xyz[6] = "USDCHF"; xyz[7] = "USDJPY"; xyz[9] = "AUDUSD";
You can NOT access uninitialized strings. xyz[8] and xyz[10..]
If these are constant, you can initialze them withstring xyz[]={ "USDCAD", "USDCHF", "EURUSD", "USDJPY", "AUDUSD", "USDCHF", "USDCHF", "USDJPY", "AUDUSD"};
Pass the array and
return a valueAlert( countXYZ("USDCHF", xyz, 9) ); return(0); } int countXYZ (string x, string xyz[], int n){ int count=0; for(int i=n-1; i>=0; i--) if (xyz[i]==x) count++; return(count); }
What are Function return values ? How do I use them ? - MQL4 forumor Alert( countXYZ("USDCHF", xyz) ); return(0); } int countXYZ (string x, string xyz[], n=WHOLE_ARRAY){ if (n==WHOLE_ARRAY) n = ArraySize(xyz); int count=0; for(int i=n-1; i>=0; i--) if (xyz[i]==x) count++; return(count); }

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
How can I count the number of items in an array that have the value of "USDCHF"?