iRSI will either be above 75, or below.
True or false.
1 or 0
how to get the value of the indicator ?
In MQL4 (are you using MQL4?):
-
Play videoPlease edit your post.
For large amounts of code, attach it - Don't write code like that.
It could be interpreted as assign to a the RSI value, then test the value. if (a=(iRSI(NULL,0,14,PRICE_CLOSE,0)>75)) {
int b=a-3
}What it actually does (per the parentheses) is compare the RSI to 75 and then assign the result (0 or 1) to a and then test a.
Since a is 0 or 1, b makes no sense.
if (a=(iRSI(NULL,0,14,PRICE_CLOSE,0)>75)) {
int b=a-3
}Make it obvious.
Code becomes self-documenting when you use meaningful variable names, A and b say nothing. You should be able to read the code out loud and have it make sense. "Aye is greater than 75" doesn't, "current RSI is over bought," does.
#define OVER_BOUGHT 75 double currentRSI = iRSI(NULL, 0, 14, PRICE_CLOSE, 0); if(currentRSI > OVER_BOUGHT){ int b=a-3 }
- Why did you post MT4 code in the MT5 forum (Automated Trading and Strategy Testing Forum / Expert Advisors and Automated Trading - MQL5 programming forum) instead of the MT4 forum (Automated Trading and Strategy Testing Forum / MQL4 and MetaTrader 4 - MQL4 programming forum)?
Hi
Thanks for the quick responseYes, I am using MQL4, and I am sorry I posted in MT5 I did not pay attention.
Thanks to you now I did get the numeric value of the indicator.
What I'm trying to do is to close order when the RSI crosses the 75 but drops back to 72
So I tried the following:
double currentRSI = iRSI(NULL, 0, 14, PRICE_CLOSE, 0);
if(currentRSI > OVER_BOUGHT){
if(CloseBuyOrder=75-3){
OrderClose(order_id,1,Ask,3,Red);
}
}
Hi
Thanks for the quick responseYes, I am using MQL4, and I am sorry I posted in MT5 I did not pay attention.
Thanks to you now I did get the numeric value of the indicator.
What I'm trying to do is to close order when the RSI crosses the 75 but drops back to 72
So I tried the following:
double currentRSI = iRSI(NULL, 0, 14, PRICE_CLOSE, 0);
if(currentRSI > OVER_BOUGHT){
if(CloseSellOrder=75-3){
OrderClose(order_id,1,Ask,3,Red);
}
}
it should be if the RS! > over_bought CloseSellOrder
static bool was_OB = false;
double currentRSI = iRSI(NULL, 0, 14, PRICE_CLOSE, 0);
if(currentRSI > OVER_BOUGHT) was_OB = true;
else if(was_OB && currentRSI < OVER_BOUGHT-3) OrderClose(order_id,1,Ask,3,Red);
Just remember to reset the value of was_OB to false when you open an order
Hi All
Thank you very much for your help
Regards
Shay

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
For example:
int b=a-3
}
how to get the value of the indicator ?
Please help
Thanks in advance
Shay