Download MetaTrader 5

Moving Average of the RSI Indicator

To add comments, please log in or register
Bill Russell
23
Bill Russell  

This has got to be the most frustrating search ever! I am looking for a simple indicator:

A moving average (where type can be selected: SMA, EMA, etc.) along with period (also an input) of the RSI, which would allow for you to specify the period of the RSI as well.

For example,

Three inputs: MA Type=SMA, SMA Period=7 and RSI Period=13. Plotted like the standard RSI with 20,50 and 80 levels.

I have a custom indicator builder, but absolutely no instructions on how to build an indicator off of another one. Additionally, MT4 instructions don't make much sense either. Can someone help? Any would be greatly appreciated.

Simon Gniadkowski
Moderator
18040
Simon Gniadkowski  

Everything is "simple" when someone is asking someone else to do it for them . . . and it is always complicated when someone is doing it for someone else.

Start here and your "simple" Indicator won't take you long to do . . . or if you want an even simpler way just click here: MT4 & MT5 Indicators coded for you

Tjipke de Vries
6398
Tjipke de Vries  

Something like this....

Bill Russell
23
Bill Russell  
deVries:

Something like this....


Thanks for the reply Devries. Red line is the 7-period SMA of the 13-period RSI?
Brian Dee - Random Trader
1760
Brian Dee - Random Trader  

Or see the SFX_MA_On_RSI indi here

The input parameters are

extern int RSI.Period = 14;
extern int RSI.Applied.Price = 0;

extern int MA.Fast.Period = 4;
extern int MA.Fast.Method = 1; // // 0=SMA 1=EMA 2=Smoothed 3=Linear Weighted
extern int MA.Fast.Shift = 0;


extern int MA.Slow.Period = 8;
extern int MA.Slow.Method = 2; // // 0=SMA 1=EMA 2=Smoothed 3=Linear Weighted
extern int MA.Slow.Shift = 0;
extern int Slow.Applied.Price = 0;


/* Applied.Price
PRICE_CLOSE 0 Close price. 
PRICE_OPEN 1 Open price. 
PRICE_HIGH 2 High price. 
PRICE_LOW 3 Low price. 
PRICE_MEDIAN 4 Median price, (high+low)/2. 
PRICE_TYPICAL 5 Typical price, (high+low+close)/3. 
PRICE_WEIGHTED 6 Weighted close price, (high+low+close+close)/4. 
*/

Good Luck

-BB-

Tjipke de Vries
6398
Tjipke de Vries  
brruss1:

Thanks for the reply Devries. Red line is the 7-period SMA of the 13-period RSI?


Yes it is....

This indicator is RSI with a calculated average of it

You can LEARN how to make it Take RSI indicator and put in coding

another buffer calculated by ==> iMAOnArray(RSI_Buffer,0,SignalLine_Period,SignalLineShift,SignalLineMa_Method,i);

We will only help if you trie something yourself

If you wanna have the version I have Then MT4 & MT5 Indicators coded for you or contact me personally

Bill Russell
23
Bill Russell  

Hello Guys,

I used the existing code from the TDI indicator which derives all MAs from the RSI, and removed the components I did not want, namely the Volatility bands and the other MA. I thinks it clear that I removed something necessary or did not define "i" appropriately. It compiled just fine and pulled to the chart, but no MA shows up, just a balck space with the 68, 50 and 32 levels. I initially received code errors regarding the definition of "i", which I managed to borrow again to get it to compile. Perhaps I missed something vitally important to making this work. Maybe you wouldn't mind having a look? Really appreciate all your help thus far.

Code follows:

#property indicator_buffers 2
#property indicator_color1 Black
#property indicator_color2 Green
#property indicator_separate_window
//--- input parameters
extern int RSI_Period = 13; //8-25
extern int RSI_Price = 0; //0-6
extern int RSI_MA_Period = 2;
extern int RSI_MA_Type = 0; //0-3
//--- buffers
double RSIBuf[],MaBuf[];

int init()
{
IndicatorShortName("MA of the RSI");
SetIndexBuffer(0,RSIBuf);
SetIndexBuffer(1,MaBuf);


SetIndexStyle(0,DRAW_NONE);
SetIndexStyle(1,DRAW_LINE); //,0,2

SetIndexLabel(0,NULL);
SetIndexLabel(1,"MA of the RSI");

SetLevelValue(0,50);
SetLevelValue(1,68);
SetLevelValue(2,32);
SetLevelStyle(STYLE_DOT,1,DimGray);

return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int start()
{
double MA,RSI[];
ArrayResize(RSI,RSI_MA_Period);
int counted_bars=IndicatorCounted();
int limit = Bars-counted_bars-1;
for(int i=limit; i>=0; i--)

RSIBuf[i] = (iRSI(NULL,0,RSI_Period,RSI_Price,i));
MA = 0;
for(int x=i; x<i; x++) {
RSI[x-i] = RSIBuf[x];
MA += RSIBuf[x]/RSI_MA_Period;
}

{
MaBuf[i] = (iMAOnArray(RSIBuf,0,RSI_MA_Period,0,RSI_MA_Type,i));
}
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+

Tjipke de Vries
6398
Tjipke de Vries  

for coding use SRC

#property copyright ""
#property link      ""

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_color1 Black   //RSI color
#property indicator_color2 Green
#property indicator_level1 32      //SetLevelValue(0,50);
#property indicator_level2 50      //SetLevelValue(1,68);
#property indicator_level3 68      //SetLevelValue(2,32);
#property indicator_levelcolor DimGray      //color indicator value

//--- input parameters
extern int RSI_Period    = 13;    //8-25
extern int RSI_Price     =  0;     /*PRICE_CLOSE    0   Close price. 
                                     PRICE_OPEN     1   Open price. 
                                     PRICE_HIGH     2   High price. 
                                     PRICE_LOW      3   Low price. 
                                     PRICE_MEDIAN   4   Median price, (high+low)/2. 
                                     PRICE_TYPICAL  5   Typical price, (high+low+close)/3. 
                                     PRICE_WEIGHTED 6   Weighted close price, (high+low+close+close)/4. */
extern int RSI_MA_Period = 7; 
extern int RSI_MA_Type = 0;       // 0 SMA , 1 EMA , 2 SMMA , 3 LWMA
//--- buffers
double RSIBuf[];
double MaBuf[];

int init()
{
IndicatorShortName("MA of the RSI");

//---- drawing settings  RSI  (0,......)
SetIndexBuffer(0,RSIBuf);
SetIndexLabel(0,"RSI");                    //SetIndexLabel(0,NULL); wrong
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);  //SetIndexStyle(0,DRAW_NONE);wrong this is draw nothing

//---- drawing settings of Moving Average on RSI
SetIndexBuffer(1,MaBuf);
SetIndexLabel(1," ("+RSI_MA_Period+") Period MA of RSI");       //SetIndexLabel(1,"MA of the RSI");
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);                       //SetIndexStyle(1,DRAW_LINE);




//SetLevelValue(0,50);
//SetLevelValue(1,68);
//SetLevelValue(2,32);
//SetLevelStyle(STYLE_DOT,1,DimGray);

return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int start()
{
double MA,RSI[];
ArrayResize(RSI,RSI_MA_Period);
int counted_bars=IndicatorCounted();
int limit = Bars-counted_bars-1;
for(int i=limit; i>=0; i--)

RSIBuf[i] = (iRSI(NULL,0,RSI_Period,RSI_Price,i)); 
MA = 0;
for(int x=i; x<i; x++) {
RSI[x-i] = RSIBuf[x];
MA += RSIBuf[x]/RSI_MA_Period;
}

for(int j=limit; j>=0; j--)       //was missing
   {MaBuf[j] = (iMAOnArray(RSIBuf,0,RSI_MA_Period,0,RSI_MA_Type,j));}

//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+

This will do it....

Bill Russell
23
Bill Russell  

Thanks so much DeVries. Looks perfect and has allowed me to move ahead leaps and bounds on getting my trading programmed into an EA. Can't thank you enough!

keekko
5
keekko  

Hi!

Is it possible to apply the second MA on RSI ( 9SMA&45EMA, RSI14 ) ? I used esignal with my former broker but now I switched and they only offer mt4. Thanks in advance.

brruss1:

Thanks so much DeVries. Looks perfect and has allowed me to move ahead leaps and bounds on getting my trading programmed into an EA. Can't thank you enough!

whroeder1
16286
whroeder1  
Yes, drag the ma to the subchart and select previous/first indicator for price.
12
To add comments, please log in or register