Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
FX_Sniperfs_T3_CCI_fixed
//+------------------------------------------------------------------+
//| FX Sniper's T3 CCI fixed.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 Blue
#property indicator_color2 Green
#property indicator_color3 Red
//----
extern int CCI_Period = 14;
extern int T3_Period = 5;
extern double b = 0.618;
//----
double e1, e2, e3, e4, e5, e6;
double c1, c2, c3, c4;
double n, w1, w2, b2, b3;
double cci[];
double cciHup[];
double cciHdn[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---- indicators setting
SetIndexBuffer(0, cci);
SetIndexBuffer(1, cciHup);
SetIndexBuffer(2, cciHdn);
//----
SetIndexStyle(0, DRAW_LINE);
SetIndexStyle(1, DRAW_HISTOGRAM);
SetIndexStyle(2, DRAW_HISTOGRAM);
//----
IndicatorShortName("FXST3CCI(" + CCI_Period + ", " + T3_Period + ")");
SetIndexLabel(0, "FXST3CCI");
SetIndexLabel(1, NULL);
SetIndexLabel(2, NULL);
IndicatorDigits(_Digits);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
int limit=1;
if(rates_total-prev_calculated<0) return(0);
if (prev_calculated==0 || rates_total-prev_calculated>1)
{
varReset();
limit=rates_total-1;
}
//---- indicator calculation
if(rates_total-prev_calculated>=1)
{
for(int i = limit; i >= 1; i--)
{
cci[i] = iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, i);
e1 = w1*cci[i] + w2*e1;
e2 = w1*e1 + w2*e2;
e3 = w1*e2 + w2*e3;
e4 = w1*e3 + w2*e4;
e5 = w1*e4 + w2*e5;
e6 = w1*e5 + w2*e6;
cci[i] = c1*e6 + c2*e5 + c3*e4 + c4*e3;
//----
if(cci[i] >= 0)
cciHup[i] = cci[i];
else
cciHup[i] = 0;
//----
if(cci[i] < 0 )
cciHdn[i] = cci[i];
else
cciHdn[i] = 0;
}
}
//---- zero bar calculation
cci[0] = iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, 0);
double tmp_e1 = w1*cci[0] + w2*e1;
double tmp_e2 = w1*tmp_e1 + w2*e2;
double tmp_e3 = w1*tmp_e2 + w2*e3;
double tmp_e4 = w1*tmp_e3 + w2*e4;
double tmp_e5 = w1*tmp_e4 + w2*e5;
double tmp_e6 = w1*tmp_e5 + w2*e6;
cci[0] = c1*tmp_e6 + c2*tmp_e5 + c3*tmp_e4 + c4*tmp_e3;
//----
if(cci[0] >= 0)
cciHup[0] = cci[0];
else
cciHup[0] = 0;
//----
if(cci[0] < 0 )
cciHdn[0] = cci[0];
else
cciHdn[0] = 0;
//----
return(rates_total);
}
//+------------------------------------------------------------------+
void varReset()
{
//---- variable reset
b2 = b*b;
b3 = b2*b;
c1 = -b3;
c2 = (3*(b2 + b3));
c3 = -3*(2*b2 + b + b3);
c4 = (1 + 3*b + b3 + 3*b2);
n = T3_Period;
//----
if(n < 1)
n = 1;
n = 1 + 0.5*(n - 1);
w1 = 2 / (n + 1);
w2 = 1 - w1;
}
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
---