How to read or get the RSI or any indicator parameters in runtime

 

Hi all, I would like to know if there is a way to read or get for example the parameters of RSI in runtime as image below:


 

Hello, it is possible with the function IRSI. U can create an handle variable, memorizing the value of RSI in it with iRSI call:


int   iRSI(
   string              symbol,             // symbol's name
   ENUM_TIMEFRAMES     period,   // symbol's period   
   int                 ma_period,         // RSI period
   ENUM_APPLIED_PRICE  applied_price      // price type
   );


For example ------>   int handle=iRSI(_Symbol,_Period,14,PRICE_CLOSE)

And in the variable handle u will have the value of RSI (14 period for example), calculated on price close on the current Cross/Period u have on the chart.

So u can Comment it on the chart with function Comment, or print, or do also an alert. :)

 
MichTrader:

Hello, it is possible with the function IRSI. U can create an handle variable, memorizing the value of RSI in it with iRSI call:


int   iRSI(
   string              symbol,             // symbol's name
   ENUM_TIMEFRAMES     period,   // symbol's period   
   int                 ma_period,         // RSI period
   ENUM_APPLIED_PRICE  applied_price      // price type
   );


For example ------>   int handle=iRSI(_Symbol,_Period,14,PRICE_CLOSE)

And in the variable handle u will have the value of RSI (14 period for example), calculated on price close on the current Cross/Period u have on the chart.

So u can Comment it on the chart with function Comment, or print, or do also an alert. :)

Not true.

Please check the documentation for iRSI

You will need to get the value with CopyBuffer()

 
MichTrader:

Hello, it is possible with the function IRSI. U can create an handle variable, memorizing the value of RSI in it with iRSI call:


int   iRSI(
   string              symbol,             // symbol's name
   ENUM_TIMEFRAMES     period,   // symbol's period   
   int                 ma_period,         // RSI period
   ENUM_APPLIED_PRICE  applied_price      // price type
   );


For example ------>   int handle=iRSI(_Symbol,_Period,14,PRICE_CLOSE)

And in the variable handle u will have the value of RSI (14 period for example), calculated on price close on the current Cross/Period u have on the chart.

So u can Comment it on the chart with function Comment, or print, or do also an alert. :)

Hello and thanks for the answer, but this is not what I am looking for. I mean, I need to read the RSI parameters in runtime from the RSI subwindow  that I previously have opened by Insert Menu of Metatrader 4 or 5, if I change for example the RSI period (14) by right-clicking over the subwindow on the chart and edit properties then I need to get that value from code in runtime and then I can use that value as I want.

 
Jhojan Alberto Tobon Monsalve:

Hello and thanks for the answer, but this is not what I am looking for. I mean, I need to read the RSI parameters in runtime from the RSI subwindow  that I previously have opened by Insert Menu of Metatrader 4 or 5, if I change for example the RSI period (14) by right-clicking over the subwindow on the chart and edit properties then I need to get that value from code in runtime and then I can use that value as I want.

I hope i get ur message right. Do  you mean you want to change rsi parameter whenever your ea are running? If that the case, 1) you need to establish in global extern int RSIperiod = 14  ; 2) insert RSIperiod into rsi parameter 
 
Cosmas Moses:
I hope i get ur message right. Do  you mean you want to change rsi parameter whenever your ea are running? If that the case, 1) you need to establish in global extern int RSIperiod = 14  ; 2) insert RSIperiod into rsi parameter 

No, I just need to get  or read that parameter from an existing indicator, RSI in this case as simple as that:

For example I have the indicator in the chart. right?

How can I read, get, obtain, grab this value in runtime from code?. I know that I need first to find the indicator in the chart and then I want to get all the parameters the indicator has. How can I achieve that goal?. I don´t want to set the value but get it. I don´t want to create de RSI from code, what I need is to read the parameters of the RSI  that I previously put into the chart from de Insert->Indicators->RSI.

 
Jhojan Alberto Tobon Monsalve:

No, I just need to get  or read that parameter from an existing indicator, RSI in this case as simple as that:

For example I have the indicator in the chart. right?

How can I read, get, obtain, grab this value in runtime from code?. I know that I need first to find the indicator in the chart and then I want to get all the parameters the indicator has. How can I achieve that goal?. I don´t want to set the value but get it. I don´t want to create de RSI from code, what I need is to read the parameters of the RSI  that I previously put in the chart from de Insert->Indicators->RSI.

basically , you want a function to read the indicator parameter such as period , mode  etc ... so far i haven found any func that would tackle this problem  . Might other have solutions for this . 

 

Hi all, I just discovered how to make it in MQL5 but not in MQL4, Does somebody know how to convert it into MQL4?

void OnStart() 
  { 
  
//--- The number of windows on the chart (at least one main window is always present) 
   int windows=(int)ChartGetInteger(0,CHART_WINDOWS_TOTAL); 
//--- Go through the chart windows 
   for(int w=0;w<windows;w++) 
     { 
      //--- The number of indicators in this window/subwindow 
      int total=ChartIndicatorsTotal(0,w); 
      //--- Take all indicators in the window 
      for(int i=0;i<total;i++) 
        { 
         //--- Get the short name of the indicator 
         string name=ChartIndicatorName(0,w,i); 
         //--- Get the indicator handle 
         int handle=ChartIndicatorGet(0,w,name); 
         //--- Add to log 
         
         
         PrintFormat("Window=%d,  indicator #%d,  handle=%d",w,i,handle); 
         //--- 
         MqlParam parameters[]; 
         ENUM_INDICATOR indicator_type; 
         int params=IndicatorParameters(handle,indicator_type,parameters); 
         IndicatorDigits
         //--- The header of the message 
         string par_info="Short name "+name+", type " 
                         +EnumToString(ENUM_INDICATOR(indicator_type))+"\r\n"; 
         //---  
         for(int p=0;p<params;p++) 
           { 
            par_info+=StringFormat("parameter %d: type=%s, long_value=%d, double_value=%G,string_value=%s\r\n", 
                                   p, 
                                   EnumToString((ENUM_DATATYPE)parameters[p].type), 
                                   parameters[p].integer_value, 
                                   parameters[p].double_value, 
                                   parameters[p].string_value 
                                   ); 
           } 
         Print(par_info); 
        } 
      //--- Done for all indicators in the window 
     } 
//---     
  }
 
Jhojan Alberto Tobon Monsalve: How can I read, get, obtain, grab this value in runtime from code?.

You don't. EAs have no eyes. They don't need the indicator on the chart.

 
William Roeder:

You don't. EAs have no eyes. They don't need the indicator on the chart.

Well, I do need it this way. The code above is taken directly from MQL5 library btw, and works as I wanted. I only need this code for MQL4. Any idea?

 
Jhojan Alberto Tobon Monsalve:

Well, I do need it this way. The code above is taken directly from MQL5 library btw, and works as I wanted. I only need this code for MQL4. Any idea?

in mql5 "  IndicatorParameters()  " return the number of input parameters of the indicator which something that you are looking for , meanwhile in mql4 not much can do . As shown picture below , we can see mql5 offer much better Timeseries and indicator Access compare to mql4. 


mql4 vs mql5