Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
+RSI_mtf
//+------------------------------------------------------------------+
//| +RSI_mtf.mq4 |
//| Copyright © 2008, masemus |
//| masemus@yahoo.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, masemus"
#property link "masemus@yahoo.com"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 SeaGreen
#property indicator_color2 FireBrick
#property indicator_color3 Red
#property indicator_color4 DarkKhaki
#property indicator_width1 1
#property indicator_width2 1
#property indicator_width3 1
#property indicator_width4 1
#property indicator_level1 0.0
#property indicator_levelcolor Silver
#property indicator_levelstyle STYLE_DOT
//---- input parameters
extern int TF=5;
extern int RSI_01=14;
extern int RSI_02=70;
extern int Price_Type=5;
// Price_Type ---------+
// 0 = PRICE_CLOSE |
// 1 = PRICE_OPEN |
// 2 = PRICE_HIGH |
// 3 = PRICE_LOW |
// 4 = PRICE_MEDIAN |
// 5 = PRICE_TYPICAL |
// 6 = PRICE_WEIGHTED |
//+--------------------+
//---- indicator buffers
double ExtLimeBuffer[];
double ExtRedBuffer[];
double ExtTrend[];
double ExtTrend2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- additional buffers are used for counting
IndicatorBuffers(4);
//---- drawing settings
IndicatorDigits(4);
SetIndexDrawBegin(0,34);
SetIndexDrawBegin(1,34);
//---- indicator buffers mapping
SetIndexStyle(0,DRAW_HISTOGRAM);
SetIndexStyle(1,DRAW_HISTOGRAM);
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(0,ExtLimeBuffer);
SetIndexBuffer(1,ExtRedBuffer);
SetIndexBuffer(2,ExtTrend);
SetIndexBuffer(3,ExtTrend2);
SetIndexLabel(0,NULL);
SetIndexLabel(1,NULL);
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Trend |
//+------------------------------------------------------------------+
int start()
{
int i,limit,Bshift,counted_bars=IndicatorCounted();
double prev,current;
string Teks01 = "", Teks02 = "";
//+------------------------------------------------------------------+
string MTF="";
double cTF=Period();
if (cTF==PERIOD_M1) { MTF="M1"; }
if (cTF==PERIOD_M5) { MTF="M5"; }
if (cTF==PERIOD_M15) { MTF="M15"; }
if (cTF==PERIOD_M30) { MTF="M30"; }
if (cTF==PERIOD_H1) { MTF="H1"; }
if (cTF==PERIOD_H4) { MTF="H4"; }
if (cTF==PERIOD_D1) { MTF="D1"; }
if (cTF==PERIOD_W1) { MTF="W1"; }
if (cTF==PERIOD_MN1) { MTF="MN1"; }
else if (TF == 1) { MTF="M1"; }
else if (TF == 5) { MTF="M5"; }
else if (TF == 15) { MTF="M15"; }
else if (TF == 30) { MTF="M30"; }
else if (TF == 60) { MTF="H1"; }
else if (TF == 240) { MTF="H4"; }
else if (TF == 1440) { MTF="D1"; }
else if (TF == 10080) { MTF="W1"; }
else if (TF == 43200) { MTF="MN1"; }
//+------------------------------------------------------------------+
//---- last counted bar will be recounted
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars+TF/Period();
for(i=limit; i>=0; i--)
{
Bshift = iBarShift(Symbol(),TF,Time[i]);
ExtTrend[i]=iRSI(Symbol(),TF,RSI_01,Price_Type,Bshift)
-iRSI(Symbol(),TF,RSI_02,Price_Type,Bshift);
ExtTrend2[i]=iRSI(Symbol(),0,RSI_01,Price_Type,i)
-iRSI(Symbol(),0,RSI_02,Price_Type,i);
//----
bool up=true;
current=iRSI(Symbol(),TF,RSI_01,Price_Type,Bshift)
-iRSI(Symbol(),TF,RSI_02,Price_Type,Bshift);
prev=iRSI(Symbol(),TF,RSI_01,Price_Type,Bshift+1)
-iRSI(Symbol(),TF,RSI_02,Price_Type,Bshift+1);
if(current>0) {Teks01="UP";}
if(current<0) {Teks01="DN";}
if(current==0) {Teks01="SW";}
if(current>prev) up=true;
if(current<prev) up=false;
if(!up)
{
ExtRedBuffer[i]=current;
ExtLimeBuffer[i]=0.0;
Teks02="DN";
}
else
{
ExtLimeBuffer[i]=current;
ExtRedBuffer[i]=0.0;
Teks02="UP";
}
}
//---- name for DataWindow and indicator subwindow label
IndicatorShortName("+RSI_["+RSI_01+","+RSI_02+"] "+MTF+" :: TREND_["+Teks01+"] SiGNAL_["+Teks02+"]");
//---- done
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
---