How to use iRSI function to get the value of RSI on the last bar in a chart
What didn't work ? Please show your code if you need coding help.
It does not return the value of RSI, it returns 10 even when I changed the symbol or timeframe
#property indicator_chart_window #property indicator_buffers 1 #property indicator_plots 1 double iRSIBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { CopyBuffer(iRSI(_Symbol,PERIOD_H4,14,PRICE_CLOSE),0,0,1,iRSIBuffer); double irsiv = iRSIBuffer[0]; Comment (irsiv); if(irsiv<30.00) { Alert("Buy"); } return(rates_total); }it shows the comment (irsiv value) correctly, but it does not show the alert correctly (the if clause does not work)
it shows the comment (irsiv value) correctly, but it does not show the alert correctly (the if clause does not work)
Hi dude, I have the same issue, could you make it work?
I'm having the same proble with my code. It just prints out 10.0 constantly, also if I try it with iMA
//+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- double rsi = iRSI(NULL,0, 14, PRICE_CLOSE); //double movingAverage = iMA(NULL,0,15,0,MODE_SMA,PRICE_MEDIAN); Alert(rsi); } //+------------------------------------------------------------------+
Of course, it does.
- What does iRSI return?
- Why are you calling it outside of OnInit?
I'm just starting to use MQL5 and when I try to call the rsi, my terminal just prints 10 constanly. Here is the sample code:
Read the documentation
- www.mql5.com
Unfortunately the example in the documetation is a bit overkill for newbies. I was struggeling with the same issue.
IMHO the following article has a pretty good explanation for this issue:
https://www.mql5.com/en/articles/43
Have a look into the section: Connecting indicators
- www.mql5.com
Hi guys,
I used iRSI function in following format
int iRSI(
string symbol, // symbol name
ENUM_TIMEFRAMES period, // period
int ma_period, // averaging period
ENUM_APPLIED_PRICE applied_price // type of price or handle
);
in an indicator to get the value of RSI on the last bar of a chart, but it did not work, does it need extra code or I am doing something wrong.
Thanks