Get RSI Period

 

Hello,

I want to get period of current RSI indicator. Does anybody know how I can get it in MQL4 or MQL5?

Thanks

 
You don't get anything. You set it when you put it on the chart.
 
Mansour Mansouri:

Hello,

I want to get period of current RSI indicator. Does anybody know how I can get it in MQL4 or MQL5?

Thanks

Salam!

void OnStart() { 
   int windows=(int)ChartGetInteger(0,CHART_WINDOWS_TOTAL); 
   for(int w=0;w<windows;w++) { 
      int total=ChartIndicatorsTotal(0,w); 
      for(int i=0;i<total;i++) {
         string name=ChartIndicatorName(0,w,i); 
         if(StringFind(name,"RSI(",0)!=-1){
            int startPos  = (int) StringFind(name,"(",0)+1;                       // or use 4 as it is clear where to start
            int endPos    = (int) StringFind(name,")",0);
            int rsiPeriod = (int) StringSubstr(name,startPos,endPos-startPos);
         }
      } 
   } 
}
 
_MAHA_ #:

Salam!

Great MAHA, That's it !!

Thanks

 
William Roeder #:
You don't get anything. You set it when you put it on the chart.

Hello William,

I need to know what RSI period  is on the chart in my EA.

Do you know how we can put RSI on the chart within EA? We get RSI parameters from user and we put appropriate RSI on chart.

 

Mansour Mansouri #: I need to know what RSI period  is on the chart in my EA.

  1. There is no generalized way to know what is on the chart. The human put the RSI on the chart. Only the human knows.
  2. The EA has no eyes. It doesn't need anything on the chart. Add an input to your EA and let the human tell you.
 
William Roeder #:
  1. There is no generalized way to know what is on the chart. The human put the RSI on the chart. Only the human knows.
  2. The EA has no eyes. It doesn't need anything on the chart. Add an input to your EA and let the human tell you.

 I want to do the same. Add an input to my EA and human tell me. But I do not know how to put RSI on the chart according to these inputs.

 
Mansour Mansouri #:

 I want to do the same. Add an input to my EA and human tell me. But I do not know how to put RSI on the chart according to these inputs.

IndicatorAdd

Documentation on MQL5: Standard Library / Price Charts / IndicatorAdd
Documentation on MQL5: Standard Library / Price Charts / IndicatorAdd
  • www.mql5.com
IndicatorAdd(int,int) - Price Charts - Standard Library - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Mansour Mansouri #: But I do not know how to put RSI on the chart according to these inputs.

What part of “the EA has no eyes. It doesn't need anything on the chart” was unclear to you?

 
_MAHA_ #:

IndicatorAdd

What about MT4?

 
Mansour Mansouri #: What about MT4?

Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
          General rules and best pratices of the Forum. - General - MQL5 programming forum? (2017)
Next time, post in the correct place. The moderators will likely move this thread there soon.

Reread answers #1m #5

Reason: