i create a custom function but i dont know how to get the value from it and compare them in if statement
- Mega system Pack
- need some help for custom functions
- how do i compare 2 bars ?
DD
Examples
int iCheckBar; iCheckBar = checkbar(); if (iCheckBar == 1) { // Do something } if (iCheckBar == 2) { // Do something else }
you could also paramaetize the function as
double checkbarshift(int iShift) { popen = iOpen(Symbol(),0,iShift); pclose = iClose(Symbol(),0,iShift); phigh = iHigh(Symbol(),0,iShift); plow = iLow(Symbol(),0,iShift); int barshift; if (popen > pclose) barshift = 1; if (popen < pclose) barshift = 2; if ((popen + pclose)/2 > popen) barshift = 3; return (barshift); }
which allows reuse of code in a handy way, such as
int iCheckBar1, icheckBar2; iCheckBar1 = checkbarshift(1); iCheckBar2 = checkbarshift(2); if ((iCheckBar1 == 1) && (iCheckBar2 == 1)) { // Do something } if ((iCheckBar1 == 2) && (iCheckBar2 == 2)) { // Do something else }
Good Luck
-BB-
oh, thank you for the reply, things getting clear in my ea now, also that bar shift example is awsome, never though about that
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