Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
EMA_RSI_Signal
//+------------------------------------------------------------------+
//| EMA_RSI_Signal.mq4 |
//| Copyright © 2006, MetaQuotes Software Corp. |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
#property link "Code adapted by cja"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_width1 2
#property indicator_width2 2
extern bool Alert_ON = true;
extern bool POP_UP_ON = true;
extern int EMA_Fast = 10;
extern int EMA_Slow = 40;
extern int RSI = 9;
extern int ARROW_Distance = 15;
double CrossUp[];
double CrossDown[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, DRAW_ARROW);
SetIndexArrow(0, 233);
SetIndexBuffer(0, CrossUp);
SetIndexStyle(1, DRAW_ARROW);
SetIndexArrow(1, 234);
SetIndexBuffer(1, CrossDown);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
static datetime dt = 0;
int limit, i, counter;
double RRSI,EMA_FFast,EMA_SSlow,EMA_FFast_Prev,EMA_SSlow_Prev;
double Range, AvgRange;
int counted_bars=IndicatorCounted();
//---- check for possible errors
if(counted_bars<0) return(-1);
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
static datetime cDT = 0;
for(i = 0; i <= limit; i++) {
counter=i;
Range=0;
AvgRange=0;
CrossUp[i] = 0; CrossDown[i] = 0;
for (counter=i ;counter<=i+ARROW_Distance ;counter++)// distance star above/below price
{
AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
}
Range=AvgRange/10;
RRSI = iRSI(NULL,0, RSI, PRICE_CLOSE,i);
EMA_FFast = iMA(NULL,0,EMA_Fast,0,MODE_EMA,PRICE_CLOSE,i);
EMA_FFast_Prev = iMA(NULL,0,EMA_Fast,0,MODE_EMA,PRICE_CLOSE,i+1);
EMA_SSlow = iMA(NULL,0,EMA_Slow,0,MODE_EMA,PRICE_CLOSE,i);
EMA_SSlow_Prev = iMA(NULL,0,EMA_Slow,0,MODE_EMA,PRICE_CLOSE,i+1);
if ((EMA_FFast > EMA_SSlow) && (EMA_FFast_Prev < EMA_SSlow_Prev)&& (RRSI > 50)){
CrossUp[i] = Low[i] - Range*0.5; // range # also affects star price difference
if ((i < 2) && (dt != iTime(NULL,0,0)))
{
if (Alert_ON ==true)
{
if (POP_UP_ON ==true)
{
Alert(Symbol(),"M",Period()," : EMA["+EMA_Fast+"] EMA["+EMA_Slow+"] RSI["+RSI+"] Cross UP " );
}
PlaySound("alert.wav");
dt = iTime(NULL,0,0);
}}
}
else if ((EMA_FFast < EMA_SSlow) && (EMA_FFast_Prev > EMA_SSlow_Prev)&& (RRSI < 50)){
CrossDown[i] = High[i] + Range*0.5; // range # also affects star price difference
if ((i < 2) && (dt != iTime(NULL,0,0)))
{
if (Alert_ON ==true)
{
if (POP_UP_ON ==true)
{
Alert(Symbol()," M",Period(), " : EMA["+EMA_Fast+"] EMA["+EMA_Slow+"] RSI["+RSI+"] Cross DOWN ");
}
PlaySound("alert.wav");
dt = iTime(NULL,0,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
---