# FX Sniper: T3-CCI

Dilihat 8426
This simple indicator gives you a lot of useful information - when to enter, when to exit
and how to reduce risks by entering a trade on a double confirmed signal.
You can use in the xPrice any series: Open, High, Low, Close, HL2 , HLC3, OHLC4 and ect...
```////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 25/07/2014
// This simple indicator gives you a lot of useful information - when to enter, when to exit
// and how to reduce risks by entering a trade on a double confirmed signal.
// You can use in the xPrice any series: Open, High, Low, Close, HL2, HLC3, OHLC4 and ect...
////////////////////////////////////////////////////////////
study(title="FX Sniper:  T3-CCI", shorttitle="T3-CCI")
CCI_Period = input(14, minval=1)
T3_Period = input(5, minval=1)
b = input(0.618)
hline(0, color=purple, linestyle=line)
xPrice = close
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)
nn = iff(T3_Period < 1, 1, T3_Period)
nr = 1 + 0.5*(nn - 1)
w1 = 2 / (nr + 1)
w2 = 1 - w1
xcci = cci(xPrice, CCI_Period)
e1 = w1*xcci + w2*nz(e1[1])
e2 = w1*e1 + w2*nz(e2[1])
e3 = w1*e2 + w2*nz(e3[1])
e4 = w1*e3 + w2*nz(e4[1])
e5 = w1*e4 + w2*nz(e5[1])
e6 = w1*e5 + w2*nz(e6[1])
xccir = c1*e6 + c2*e5 + c3*e4 + c4*e3
cciHcolor = iff(xccir >= 0 , green,
iff(xccir < 0, red, black))
plot(xccir, color=blue, title="T3-CCI")
plot(xccir, color=cciHcolor, title="CCIH", style = histogram)```

## Komentar

Hi HP. Great work on this indicator and all the other ones. I was wondering if you'd have the time and be able to code the following "stepless" MTF version of it too, as the one you've provided doesn't calculate in the same way? Thanks in advance and hope you can help!

=============================================
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 clrBlue
#property indicator_color2 clrRed
#property indicator_width1 3
#property indicator_width2 3
#property indicator_levelstyle STYLE_SOLID
#property indicator_levelcolor clrDeepSkyBlue
#property indicator_levelwidth 3

// Ergo Variables
extern ENUM_TIMEFRAMES TimeFrame = PERIOD_CURRENT; // Time frame
extern int pq = 2;
extern int pr = 10;
extern int ps = 5;
extern int trigger = 3;
extern bool SoundAlert = false;
extern bool Interpolate = true; // Interpolate in mtf mode

//---- indicator buffers

string signal;
double mtm;
double absmtm;
double ErgoCCI;
double MainCCI;
double var1;
double var2;
double var2a;
double var2b;
double count;
string previous;

string indicatorFileName;

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- 2 additional buffers are used for counting.
for (int i=0; i<indicator_buffers; i++) SetIndexStyle(i,DRAW_LINE);
IndicatorBuffers(9);
SetIndexBuffer(0,ErgoCCI); SetIndexLabel(0,NULL);
SetIndexBuffer(1,MainCCI); SetIndexLabel(1,NULL);
SetIndexBuffer(2,mtm);
SetIndexBuffer(3,var1);
SetIndexBuffer(4,var2);
SetIndexBuffer(5,absmtm);
SetIndexBuffer(6,var2a);
SetIndexBuffer(7,var2b);
SetIndexBuffer(8,count);
SetLevelValue(0,0);

indicatorFileName = WindowExpertName();
TimeFrame = fmax(TimeFrame,_Period);

IndicatorShortName (timeFrameToString(TimeFrame)+" Fx_Sniper/s_Ergodic_CCI_Trigger");
return(0);
}
//+------------------------------------------------------------------+
//| Calculations |
//+------------------------------------------------------------------+
int start()
{
int i,counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
int limit=fmin(Bars-counted_bars,Bars-1); count = limit;
if (TimeFrame!=_Period)
{
limit = (int)fmax(limit,fmin(Bars-1,_mtfCall(8,0)*TimeFrame/Period()));
for (i=limit;i>=0;i--)
{
int y = iBarShift(NULL,TimeFrame,Time);
ErgoCCI = _mtfCall(0,y);
MainCCI = _mtfCall(1,y);

//
//
//
//
//

if (!Interpolate || (i>0 && y==iBarShift(NULL,TimeFrame,Time))) continue;
#define _interpolate(buff) buff = buff+(buff-buff)*k/n
int n,k; datetime time = iTime(NULL,TimeFrame,y);
for(n = 1; (i+n)<Bars && Time >= time; n++) continue;
for(k = 1; k<n && (i+n)<Bars && (i+k)<Bars; k++)
{
_interpolate(ErgoCCI);
_interpolate(MainCCI);
}
}
return(0);
}

for(i=0; i <= Bars; i++) { mtm= Close- Close; }
for(i=0; i <= Bars-1; i++) { absmtm = MathAbs(mtm); }
for(i=0; i <= Bars-1; i++) { var1= iMAOnArray(mtm,0,pq,0,MODE_EMA,i); }
for(i=0; i <= Bars-1; i++)
{
var2= iMAOnArray(var1,Bars,pr,0,MODE_EMA,i);
}
for(i=0; i <= Bars-1; i++)
{
var2a= iMAOnArray(absmtm,0,pq,0,MODE_EMA,i);
}
for(i=0; i <= Bars-1; i++)
{
var2b= iMAOnArray(var2a,0,pr,0,MODE_EMA,i);
}
for(i=0; i <= Bars-1; i++)
{
ErgoCCI = (500 * iMAOnArray(var2,0,ps,0,MODE_EMA,i))/(iMAOnArray(var2b,0,ps,0,MODE_EMA,i)); //var2a/var2b;

}
for(i=0; i<=Bars; i++)
{
MainCCI=iMAOnArray(ErgoCCI,0,trigger,0,MODE_SMA,i);
}

for(i=0; i<=Bars; i++)
{
if(previous=="") previous=signal;
if(MainCCI > ErgoCCI)
{
signal = "SHORT";
previous=signal;
}
if (MainCCI < ErgoCCI)
{
signal = "LONG";
previous=signal;
}
if (MainCCI == ErgoCCI)
{
signal = "NEUTRAL";
previous=signal;
}
}
return(0);
}
//+------------------------------------------------------------------+

//+-------------------------------------------------------------------
//|
//+-------------------------------------------------------------------
//
//
//
//
//

string sTfTable = {"M1","M5","M15","M30","H1","H4","D1","W1","MN"};
int iTfTable = {1,5,15,30,60,240,1440,10080,43200};

string timeFrameToString(int tf)
{
for (int i=ArraySize(iTfTable)-1; i>=0; i--)
if (tf==iTfTable) return(sTfTable);
return("");
=============================================
Jawab
Can this script be used in think or swim? I tried pasting the Squeeze Momentun indicator but had invalid statements so I called Hahn-Tech and they charge to port it over to think or swim.
Jawab
Is there any way this can be applied to Think or swim?
Jawab
Jawab
joe_vijay
There is a whole lot of documentation on the net. Especially in the forex forums. Sniper is a forex trader. Do a search in forexfactory.com or forex-tsd.com.
Jawab
Thank you, would you please explain by is a double confirmed signal?
Jawab
LudmilaHanania
sorry, mistype, meant to ask what is a double confirmed signal?
Jawab
LudmilaHanania
I am not an educator, but the meaning as I see it is that you should have more than one type of indicator to assess the trade you are about to make. There are basically four categories of indicators. They will measure either the trend, momentum, volatility, or volume. You want to avoid using more than one indicator out of each group. Why have multiple indicators that tell you the same thing? Instead utilize indicators that compliment each other, say one from each category to confirm your decision. Hope this helps.
Jawab
Great job HP. Thanks.
Jawab
Dare2
You are welcome
Jawab