Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
RSI_channel_sig_2
//+------------------------------------------------------------------+
//| 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 White
#property indicator_color2 Crimson
#property indicator_width2 3
#property indicator_color3 LimeGreen
#property indicator_width3 3
#property indicator_color4 Orange
#property indicator_width4 4
#property indicator_style1 STYLE_DASH
//
//
//
//
//
//
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 = true;
extern bool ShowChannel = true;
extern bool ShowZigZag = true;
extern int buyarrowwidth = 2;
extern color buyarrowcolor = Lime;
extern int sellarrowwidth = 2;
extern color sellarrowcolor = Crimson;
extern int buy1arrowwidth = 2;
extern color buy1arrowcolor = Aqua;
extern int sell1arrowwidth = 2;
extern color sell1arrowcolor = Magenta;
//
//
//
//
//
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()
{
for(int j=Bars; j>=0; j--)
{
ObjectDelete("Sell"+DoubleToStr(j,0));
ObjectDelete("Buy" +DoubleToStr(j,0));
ObjectDelete("Sell1"+DoubleToStr(j,0));
ObjectDelete("Buy1" +DoubleToStr(j,0));
}
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;
if (T3RSIBuffer[i] > LowBuffer[i] && T3RSIBuffer[i+1]==LowBuffer[i+1])
{
ObjectCreate("Buy"+DoubleToStr(i,0),OBJ_ARROW,0,Time[i],Low[i]-iATR(NULL,0,20,i)/2.0);
ObjectSet ("Buy"+DoubleToStr(i,0),OBJPROP_ARROWCODE,228);
ObjectSet ("Buy"+DoubleToStr(i,0),OBJPROP_WIDTH,buyarrowwidth);
ObjectSet ("Buy"+DoubleToStr(i,0),OBJPROP_COLOR,buyarrowcolor);
}
if (T3RSIBuffer[i] < HighBuffer[i] && T3RSIBuffer[i+1]==HighBuffer[i+1])
{
ObjectCreate("Sell"+DoubleToStr(i,0),OBJ_ARROW,0,Time[i],High[i]+iATR(NULL,0,20,i)/2.0);
ObjectSet ("Sell"+DoubleToStr(i,0),OBJPROP_ARROWCODE,230);
ObjectSet ("Sell"+DoubleToStr(i,0),OBJPROP_WIDTH,sellarrowwidth);
ObjectSet ("Sell"+DoubleToStr(i,0),OBJPROP_COLOR,sellarrowcolor);
}
if (HighBuffer[i] > HighBuffer[i+1] && HighBuffer[i+1]==HighBuffer[i+2])
{
ObjectCreate("Buy1"+DoubleToStr(i,0),OBJ_ARROW,0,Time[i],Low[i]-iATR(NULL,0,20,i)/2.0);
ObjectSet ("Buy1"+DoubleToStr(i,0),OBJPROP_ARROWCODE,225);
ObjectSet ("Buy1"+DoubleToStr(i,0),OBJPROP_WIDTH,buy1arrowwidth);
ObjectSet ("Buy1"+DoubleToStr(i,0),OBJPROP_COLOR,buy1arrowcolor);
}
if (LowBuffer[i] < LowBuffer[i+1] && LowBuffer[i+1]==LowBuffer[i+2])
{
ObjectCreate("Sell1"+DoubleToStr(i,0),OBJ_ARROW,0,Time[i],High[i]+iATR(NULL,0,20,i)/2.0);
ObjectSet ("Sell1"+DoubleToStr(i,0),OBJPROP_ARROWCODE,226);
ObjectSet ("Sell1"+DoubleToStr(i,0),OBJPROP_WIDTH,sell1arrowwidth);
ObjectSet ("Sell1"+DoubleToStr(i,0),OBJPROP_COLOR,sell1arrowcolor);
}
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
---