Price Data Components
Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
RSI_Signals
//+------------------------------------------------------------------+
//| RSI Signals.mq4 |
//| Copyright © 2010, Èâàí Òðåòüÿêîâ |
//| tretyak-off@inbox.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Èâàí Òðåòüÿêîâ"
#property link "tretyak-off@inbox.ru"
#property indicator_chart_window
#property indicator_buffers 4
//---- äëÿ RSI
#property indicator_color1 Red
#property indicator_color2 Blue
//---- input parameters
extern int RSIPeriod=14;
extern double _Up=70.0; //OverBoughtLevel - óðîâåíü ïåðåêóïëåííîñòè
extern double _Mid=50.0;
extern double _Down=30.0;//OverSoldLevel - óðîâåíü ïåðåïðîäàííîñòè
extern bool ShowMidSignals=false;
extern bool SoundON=true;
//---- çíà÷êè
extern int DownArrow=234;
extern int UpArrow=233;
//---- buffers
double UpBuffer[];
double DownBuffer[];
//---- ïåðåêëþ÷àòåëè
int flagval1=0;
int flagval2=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_ARROW);
SetIndexArrow(0,DownArrow);//Âíèç
SetIndexBuffer(0,UpBuffer);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW);
SetIndexArrow(1,UpArrow);//Ââåðõ
SetIndexBuffer(1,DownBuffer);
SetIndexEmptyValue(1,0.0);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit,i,counter;
double Range,AvgRange;
double RSIPrev,RSIAnow;
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
if(counted_bars==0) limit-=1+9;
for(i=1; i<=limit; i++)
{
counter=i;Range=0;AvgRange=0;
for(counter=i;counter<=i+9;counter++)
{AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);}
Range=AvgRange/10;
RSIPrev=iRSI(Symbol(),0,RSIPeriod,PRICE_CLOSE,i+1);
RSIAnow=iRSI(Symbol(),0,RSIPeriod,PRICE_CLOSE,i);
UpBuffer[i]=EMPTY_VALUE;
DownBuffer[i]=EMPTY_VALUE;
if((RSIPrev<_Down) && (RSIAnow>_Down))
{
if(i==1 && flagval1==0)
{
flagval1=1;
flagval2=0;
if(SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
}
DownBuffer[i]=Low[i]-Range*0.5;
UpBuffer[i]=EMPTY_VALUE;
flagval1=0;
}
if((ShowMidSignals) && ((RSIPrev<_Mid) && (RSIAnow>_Mid)))
{
if(i==1 && flagval1==0)
{
flagval1=1;
flagval2=0;
if(SoundON) Alert("BUY signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
}
DownBuffer[i]=Low[i]-Range*0.5;
UpBuffer[i]=EMPTY_VALUE;
flagval1=0;
}
if((RSIPrev>_Up) && (RSIAnow<_Up))
{
if(i==1 && flagval2==0)
{
flagval2=1;
flagval1=0;
if(SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
}
UpBuffer[i]=High[i]+Range*0.5;
DownBuffer[i]=EMPTY_VALUE;
flagval2=0;
}
if((ShowMidSignals) && ((RSIPrev>_Mid) && (RSIAnow<_Mid)))
{
if(i==1 && flagval2==0)
{
flagval2=1;
flagval2=0;
if(SoundON) Alert("SELL signal at Ask=",Ask,"\n Bid=",Bid,"\n Time=",TimeToStr(CurTime(),TIME_DATE)," ",TimeHour(CurTime()),":",TimeMinute(CurTime()),"\n Symbol=",Symbol()," Period=",Period());
}
UpBuffer[i]=High[i]+Range*0.5;
DownBuffer[i]=EMPTY_VALUE;
flagval2=0;
}
}
return(0);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---