12070 views
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...
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)
Donate BTC: 1MfdyXrs6UW8ZV5pzuB3cGHMKcYs9fy2cx
Comments
=============================================
//---- 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;
double alertTag;
string previous;
string indicatorFileName;
#define _mtfCall(_buff,_ind) iCustom(NULL,TimeFrame,indicatorFileName,PERIOD_CURRENT,pq,pr,ps,trigger,SoundAlert,_buff,_ind)
//+------------------------------------------------------------------+
//| 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";
if(SoundAlert == true && previous != signal && alertTag!=Time) {Alert("SHORT");alertTag = Time;}
previous=signal;
}
if (MainCCI < ErgoCCI)
{
signal = "LONG";
if(SoundAlert == true && previous != signal && alertTag!=Time) {Alert("LONG");alertTag = Time;}
previous=signal;
}
if (MainCCI == ErgoCCI)
{
signal = "NEUTRAL";
if(SoundAlert == true && previous != signal && alertTag!=Time) {Alert("Nuetral");alertTag = Time;}
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("");
=============================================