omissamf:
Hello to all. I need help to find out if the code I wrote is right or not.
I wrote this code to mean that the condition is valid if I cross the RSI at level 50.
Hello to all. I need help to find out if the code I wrote is right or not.
I wrote this code to mean that the condition is valid if I cross the RSI at level 50.
I would like to add an additional condition which is valid if the RSI cross the level 50 "OR" if the RSI is below the 10 level.
I wrote this code but I would like to know from the experts if it is correct:
Thank you all, Massimo.
It's not correct. You need to use && and parentheses :
double current = iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, i); double previous = iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, i+1); if(((current<50 && previous>50) || current<10) && ... ) { ... }
Thanks, angevoyageur.
But I could also write:
..... if((iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, i) < 50 && iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, i+1) > 50 || iRSI(NULL, PERIOD_CURRENT, 2, PRICE_CLOSE, i) < 10) &&............
or is it really wrong?
Massimo.
Let it become your habit if you mix && and || always use parentheses!
in your case you open 2 '(' and don't close them but - what do you want (?):
a) iRSI(1) && ( iRSI(2) || iRSI(3) ) && iRSI(4) ... or
b) (iRSI(1) && iRSI(2) ) || ( iRSI(3) && iRSI(4) ) ...
omissamf:
Thanks, angevoyageur.
It's not the same. Please read the documentation about precedence rules.
Thanks, angevoyageur.
But I could also write:
or is it really wrong?
Massimo.
gooly: Let it become your habit if you mix && and || always use parentheses!
|
|
Thank you all.
I understood.
Greetings, Massimo.
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
I wrote this code to mean that the condition is valid if I cross the RSI at level 50.
I would like to add an additional condition which is valid if the RSI cross the level 50 "OR" if the RSI is below the 10 level.
I wrote this code but I would like to know from the experts if it is correct:
Thank you all, Massimo.