Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
CCI_T3
//+------------------------------------------------------------------+
//| FX Sniper's T3 CCI.mq4 |
//| FX Sniper |
//| |
//+------------------------------------------------------------------+
#property copyright "FX Sniper: T3-CCI :-)"
#property link "http://dunno.com :-)/"
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 DodgerBlue
#property indicator_color2 LimeGreen
#property indicator_color3 Red
#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 3
#property indicator_level1 0
#property indicator_levelstyle STYLE_DASH
#property indicator_levelcolor Gold
extern int CCI_Period = 14;
extern int T3Period = 14;
extern int T3Price = PRICE_CLOSE;
extern double T3Hot = 0.7;
extern bool T3Original = true;
extern bool Histogram = true;
double emas[][6];
double alpha;
double c1;
double c2;
double c3;
double c4;
double cci[];
double cciHup[];
double cciHdn[];
int init()
{
SetIndexBuffer(0, cci);SetIndexStyle(0, DRAW_LINE);SetIndexLabel(0, "FXST3CCI");
SetIndexBuffer(1, cciHup);SetIndexStyle(1, DRAW_HISTOGRAM);SetIndexLabel(1, NULL);
SetIndexBuffer(2, cciHdn);SetIndexStyle(2, DRAW_HISTOGRAM);SetIndexLabel(2, NULL);
double a = T3Hot;
c1 = -a*a*a;
c2 = 3*a*a+3*a*a*a;
c3 = -6*a*a-3*a-3*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("CCI T3(" + CCI_Period + ", " + T3Period + ")");
return(0);
}
int start()
{
int counted_bars=IndicatorCounted();
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);
for(i=limit; i>=0; i--){ cci[i] = iT3(iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, i),i);
if(Histogram == true)
{
if(cci[i] >= 0)
cciHup[i] = cci[i];
else
cciHup[i] = 0;
//----
if(cci[i] < 0 )
cciHdn[i] = cci[i];
else
cciHdn[i] = 0;
}
}
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
---