Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
RSI_channel_
//+------------------------------------------------------------------+
//| RSI channel.mq4 |
//| mladen |
//| |
//| |
//| original idea for this indicator found on |
//| http://www.fxexpert.ru (RSI-2 posted by Dm_35) |
//| |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link "mladenfx@gmail.com"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 Gray
#property indicator_color2 Green
#property indicator_color3 Red
#property indicator_color4 Orange
#property indicator_width4 2
#property indicator_style1 STYLE_DOT
//
//
//
//
//
//
extern int RSIPeriod = 14;
extern int RSIPrice = PRICE_CLOSE;
extern int HighLowPeriod = 30;
extern int T3Period = 8;
extern double T3Hot = 0.7;
extern bool T3Original = false;
extern bool ShowChannel = true;
extern bool ShowZigZag = true;
//
//
//
//
//
double T3RSIBuffer[];
double HighBuffer[];
double LowBuffer[];
double ZigZagBuffer[];
double ZigZagLow[];
double ZigZagHigh[];
double emas[][6];
double alpha;
double c1;
double c2;
double c3;
double c4;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//
int init()
{
IndicatorBuffers(6);
SetIndexBuffer(0,ZigZagBuffer);
SetIndexBuffer(1,HighBuffer);
SetIndexBuffer(2,LowBuffer);
SetIndexBuffer(3,T3RSIBuffer);
SetIndexBuffer(4,ZigZagLow);
SetIndexBuffer(5,ZigZagHigh);
SetIndexStyle(0,DRAW_SECTION);
SetIndexEmptyValue(0,0);
SetIndexEmptyValue(3,0);
SetIndexEmptyValue(4,0);
SetIndexEmptyValue(5,0);
SetIndexLabel(0,NULL);
if (ShowChannel)
{
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
}
else
{
SetIndexStyle(1,DRAW_NONE);
SetIndexStyle(2,DRAW_NONE);
}
//
//
//
//
//
double a = T3Hot;
c1 = -a*a*a;
c2 = 3*(a*a+a*a*a);
c3 = -3*(2*a*a+a+a*a*a);
c4 = 1+3*a+a*a*a+3*a*a;
T3Period = MathMax(1,T3Period);
if (T3Original)
alpha = 2.0/(1.0 + T3Period);
else alpha = 2.0/(2.0 + (T3Period-1.0)/2.0);
//
//
//
//
//
IndicatorShortName("RSI ("+RSIPeriod+","+HighLowPeriod+","+T3Period+")");
return(0);
}
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//
int start()
{
int counted_bars = IndicatorCounted();
int lastZag;
int i,limit;
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
if (ArrayRange(emas,0) != Bars) ArrayResize(emas,Bars);
//
//
//
//
//
if (ShowZigZag)
for (lastZag=limit+1; lastZag<Bars; lastZag++) if (ZigZagLow[lastZag] != 0 || ZigZagHigh[lastZag] != 0) break;
//
//
//
//
//
for(i=limit; i>=0; i--)
{
T3RSIBuffer[i] = iT3(iRSI(NULL,0,RSIPeriod,RSIPrice,i),i);
LowBuffer[i] = T3RSIBuffer[ArrayMinimum(T3RSIBuffer,HighLowPeriod,i)];
HighBuffer[i] = T3RSIBuffer[ArrayMaximum(T3RSIBuffer,HighLowPeriod,i)];
if (!ShowZigZag) continue;
//
//
//
//
//
ZigZagLow[i] = 0;
ZigZagHigh[i] = 0;
if (LowBuffer[i] < LowBuffer[i+1])
{
if (ZigZagBuffer[lastZag] == LowBuffer[lastZag])
ZigZagBuffer[lastZag] = 0;
ZigZagBuffer[i] = LowBuffer[i];
ZigZagLow[i] = LowBuffer[i];
lastZag = i;
continue;
}
if (HighBuffer[i] > HighBuffer[i+1])
{
if (ZigZagBuffer[lastZag] == HighBuffer[lastZag])
ZigZagBuffer[lastZag] = 0;
ZigZagBuffer[i] = HighBuffer[i];
ZigZagHigh[i] = HighBuffer[i];
lastZag = i;
continue;
}
if (ZigZagBuffer[i] != 0)
{
ZigZagBuffer[i] = 0;
for (lastZag=i+1; lastZag<Bars; lastZag++)
{
if (ZigZagLow[lastZag] != 0) { ZigZagBuffer[lastZag] = ZigZagLow[lastZag]; break; }
if (ZigZagHigh[lastZag] != 0) { ZigZagBuffer[lastZag] = ZigZagHigh[lastZag]; break; }
}
}
}
//
//
//
//
//
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
//
//
//
//
//
double iT3(double price,int shift)
{
int i = Bars-shift-1;
if (i < 1)
{
emas[i][0] = price;
emas[i][1] = price;
emas[i][2] = price;
emas[i][3] = price;
emas[i][4] = price;
emas[i][5] = price;
}
else
{
emas[i][0] = emas[i-1][0]+alpha*(price -emas[i-1][0]);
emas[i][1] = emas[i-1][1]+alpha*(emas[i][0]-emas[i-1][1]);
emas[i][2] = emas[i-1][2]+alpha*(emas[i][1]-emas[i-1][2]);
emas[i][3] = emas[i-1][3]+alpha*(emas[i][2]-emas[i-1][3]);
emas[i][4] = emas[i-1][4]+alpha*(emas[i][3]-emas[i-1][4]);
emas[i][5] = emas[i-1][5]+alpha*(emas[i][4]-emas[i-1][5]);
}
return(c1*emas[i][5] + c2*emas[i][4] + c3*emas[i][3] + c4*emas[i][2]);
}
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
---