RSI indicator and MA in the same window BUT need advise on how to add an Alert

To add comments, please log in or register
jv101
26
jv101  

Hi Guys,

Please can someone help me or point me in the right direction - i have looked far and wide but still no luck...wish i knew some coding .

https://www.mql5.com/en/forum/122352

Based on the above thread... i have the RSI and the MA in the same window, my levels are 90 and 10, how can i add an sound alert when the SMA (4) touches these OB and OS levels...in tradingview its so simple but here when it comes to old school coding i'm lost,


Please can anyone help me 

RSi with Moving Average in the same window.
RSi with Moving Average in the same window.
  • 2009.12.03
  • www.mql5.com
Hello, Can you help me, please? Is it possible I can put in the same window two indicators RSi (2) and Moving Average (13) Exponential...
Files:
Seng Joo Thio
1216
Seng Joo Thio  
jv101:

Please can someone help me or point me in the right direction - i have looked far and wide but still no luck...wish i knew some coding .

I guess if you want to learn coding, the straightforward way is to create an EA to check the values of RSI and MA at the start of every new candle, and alert when their values meet your criteria. Here's where you can learn how to program in mql4. And if you need help along the way, you can post here and many of us here will help you out.

Creation of Custom Indicators - Simple Programs in MQL4 - MQL4 Tutorial
Creation of Custom Indicators - Simple Programs in MQL4 - MQL4 Tutorial
  • book.mql4.com
When creating a trading strategy a developer often faces the necessity to draw graphically in a security window a certain dependence calculated by a user (programmer). For this purpose MQL4 offers the possibility of creating custom indicators. Custom Indicator is an application program coded in MQL4; it is basically intended for graphical...
paul selvan
626
paul selvan  

1°) Test if conditions are fulfilled - e.g. SMA(4) touches OB,...

2°) If so, to get sound alert add instruction PlaySound 

Alert - Common Functions - MQL4 Reference
Alert - Common Functions - MQL4 Reference
  • docs.mql4.com
[in]  Any values separated by commas. To split the information output in several lines you can use the line feed characters "\r\n". The number of parameters can not exceed 64. Arrays can't be passed to the Alert() function. Arrays should be output elementwise. Data of the double type are output with 8 digits after the decimal point, data of the...
jv101
26
jv101  

Thank you for your inputs - i really appreciate it but ill be honest.... had a look at the links and dived into a few pages but damn.. i don't even know where to start...or what to do.. i just don't have the time to try and figure it out... not even to mention the patience to learn coding ( already trying to study the forex market so yeah my plate is full) 

It will take you guys a few minutes to code this so i'm rather willing to pay a few XRP for it if its not to expensive... let me know if anyone is interested - it will save me allot of time and heartache.

paul selvan
626
paul selvan  

rsi_ma to compile

#property strict
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 100
#property indicator_buffers 2
#property indicator_plots   2
input int      rsi_period=14;
input int      sma_period=4;
input double   rsi_OB=90;
input double   rsi_OS=10;
double         rsi[],rsi_ma[];
//+------------------------------------------------------------------+
int OnInit(){
   SetLevelValue(1,rsi_OS); SetLevelValue(2,rsi_OB);  SetLevelValue(3,50);
   SetIndexBuffer(0,rsi);   SetIndexLabel(0,"rsi");   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,clrBlue);
   SetIndexBuffer(1,rsi_ma);SetIndexLabel(1,"rsi_ma");SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,clrRed);
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
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[]){  
   int limit = MathMax(rates_total-prev_calculated,2);
   for(int i=0; i<limit; i++){  
      rsi[i]=iRSI(_Symbol,_Period,rsi_period,PRICE_CLOSE,i);
      rsi_ma[i]=rsi_ma(i);       
   }
   check_alert();
   return(rates_total);
}
//+------------------------------------------------------------------+
double rsi_ma(int i){
   double u=0;
   for(int j=i;j<i+sma_period;j++) u+=iRSI(_Symbol,_Period,rsi_period,PRICE_CLOSE,j);
   u=u/sma_period;
   return u;
}
//+------------------------------------------------------------------+
void check_alert(){
   double r1=rsi_ma(1), r0=rsi_ma(0);
   if (r1<rsi_OB && r0>=rsi_OB) { Alert("OverBought"); PlaySound("alert.wav");}
   if (r1>rsi_OS && r0<=rsi_OS) { Alert("OverSold");   PlaySound("alert.wav");}
}
jv101
26
jv101  
paul selvan:

rsi_ma to compile

Blessings to you Paul - thank you very much - i highly appreciate your effort.

Will give it a test run 

jv101
26
jv101  
paul selvan:

rsi_ma to compile

Good Day Paul,

I quickly loaded your code and placed it on a chart but i noticed it differers from my original indicator, think it might be the calculation of the SMA within the RSI that makes it "off balance" - the original indicator is merely an RSI 14 onto which i added a SMA4, added a few levels to indicate OB / OS levels and thats it, if you don't mind please can you take a look at the image attached which will make allot more sense.

Yet again thank you for your effort - i really appreciate it 

Files:
Capture.JPG 192 kb
To add comments, please log in or register