Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
RSI_on_MA_2X2_mtf
//+------------------------------------------------------------------+
//| RSIonMA2x2mtf 2RSI on 2MA RSI.mq4 |
//| Copyright © 2004, MetaQuotes Software Corp. |
//|2007fxtsd keris ki http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net/"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_color2 Crimson
#property indicator_minimum -10
#property indicator_maximum 110
#property indicator_level1 80
#property indicator_level2 50
#property indicator_level3 20
#property indicator_levelstyle 2
#property indicator_levelcolor DarkSlateGray
//---- input parameters
extern int RSI1_Period =9;
extern int MA1_Period =21;
extern int RSI2_Period =14;
extern int MA2_Period =34;
extern int MA1_Mode = MODE_EMA;
extern int MA2_Mode = MODE_EMA;
extern int MA1_Price = PRICE_CLOSE;
extern int MA2_Price = PRICE_CLOSE;
extern int TimeFrame = 0;
extern int MaxBarsToCount = 1500;
extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";
extern string MA_Method_Price = "SMA0 EMA1 SMMA2 LWMA3||0O,1C 2H3L,4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6";
//---- buffers
double RSI1_Buf[];
double RSI2_Buf[];
double MA1_Buf[];
double MA2_Buf[];
double MA1_Buf1[];
double MA2_Buf1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator line
IndicatorBuffers(6);
SetIndexBuffer(0,RSI1_Buf); SetIndexStyle(0,DRAW_LINE); SetIndexLabel(0,"");
SetIndexBuffer(1,RSI2_Buf); SetIndexStyle(1,DRAW_LINE); SetIndexLabel(1,"");
SetIndexBuffer(2,MA1_Buf); SetIndexStyle(2,DRAW_NONE); SetIndexLabel(2,"");
SetIndexBuffer(3,MA2_Buf); SetIndexStyle(3,DRAW_NONE); SetIndexLabel(3,"");
SetIndexBuffer(4,MA1_Buf1);
SetIndexBuffer(5,MA2_Buf1);
//----
SetIndexDrawBegin(0,RSI1_Period);
//----
IndicatorShortName("RSIonMA["+TimeFrame+"]: RSI1("+RSI1_Period+"|"+MA1_Period+") RSI2("+RSI2_Period+"|"+MA2_Period+")");
if (TimeFrame<Period()) TimeFrame=Period();
return(0);
}
//+------------------------------------------------------------------+
//| Relative Strength Index |
//+------------------------------------------------------------------+
int start()
{
datetime TimeArray[],TimeArray1[];
int counted_bars=IndicatorCounted();
int i,y=0,limit;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
ArrayCopySeries(TimeArray, MODE_TIME,Symbol(),TimeFrame);
ArrayCopySeries(TimeArray1,MODE_TIME,Symbol(),TimeFrame);
limit = Bars - counted_bars;
limit = MathMax(limit,TimeFrame/Period());
limit= MathMin(limit,MaxBarsToCount);
for(i=0,y=0;i<limit;i++)
{
if (Time[i]<TimeArray[y]) y++;
MA1_Buf1[i]= iMA(NULL, TimeFrame, MA1_Period,0, MA1_Mode, MA1_Price, y);
MA2_Buf1[i]= iMA(NULL, TimeFrame, MA2_Period,0, MA2_Mode, MA2_Price, y);
MA1_Buf[y]= MA1_Buf1[i];
MA2_Buf[y]= MA2_Buf1[i];
}
for(i=0,y=0;i<limit;i++)
{
if (Time[i]<TimeArray1[y]) y++;
RSI1_Buf[i] = iRSIOnArray(MA1_Buf, 0, RSI1_Period, y);
RSI2_Buf[i] = iRSIOnArray(MA2_Buf, 0, RSI2_Period, y);
}
//----
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
---