# Ergodic CSI

605 5
This is one of the techniques described by William Blau in his book
we advise you to read this book. His book focuses on three key aspects
of trading: momentum, direction and divergence. Blau, who was an electrical
engineer before becoming a trader, thoroughly examines the relationship between
price and momentum in step-by-step examples. From this grounding, he then looks
at the deficiencies in other oscillators and introduces some innovative techniques,
including a fresh twist on Stochastics. On directional issues, he analyzes the
intricacies of ADX and offers a unique approach to help define trending and
non-trending periods.
This indicator plots Ergodic CSI             and smoothed Ergodic CSI             to filter out noise.
```////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 22/07/2014
// This is one of the techniques described by William Blau in his book
// "Momentum, Direction and Divergence" (1995). If you like to learn more,
// we advise you to read this book. His book focuses on three key aspects
// of trading: momentum, direction and divergence. Blau, who was an electrical
// engineer before becoming a trader, thoroughly examines the relationship between
// price and momentum in step-by-step examples. From this grounding, he then looks
// at the deficiencies in other oscillators and introduces some innovative techniques,
// including a fresh twist on Stochastics. On directional issues, he analyzes the
// intricacies of ADX and offers a unique approach to help define trending and
// non-trending periods.
// This indicator plots Ergotic CSI and smoothed Ergotic CSI to filter out noise.
////////////////////////////////////////////////////////////
up = change(high)
down = -change(low)
trur = rma(tr, Len)
plus = fixnan(100 * rma(up > down and up > 0 ? up : 0, Len) / trur)
minus = fixnan(100 * rma(down > up and down > 0 ? down : 0, Len) / trur)
sum = plus + minus
100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), Len)

study(title="Ergodic CSI")
r = input(32, minval=1)
Length = input(1, minval=1)
BigPointValue = input(1.0, minval=0.00001)
SmthLen = input(5, minval=1)
source = close
K = 100 * (BigPointValue / sqrt(r) / (150 + 5))
xTrueRange = atr(1)
nRes = iff(Length + xTrueRange > 0, K * xADXR * xTrueRange / Length,0)
xCSI = iff(close > 0,  nRes / close, 0)
xSMA_CSI = sma(xCSI, SmthLen)
plot(xCSI, color=green, title="Ergodic CSI")
plot(xSMA_CSI, color=red, title="SigLin")```
DONATE/TIP

BTC: 1Lo1GoTNsPbrjGAgPgF4MYZPhBFdoVHaTm
I have used Fx Sniper's T3 CCI in MT4 and am including the mq4 code for same. I personally like it better than Blau's Ergodic. Would you be willing to code it for Tradingview charts? Thanks.

//+------------------------------------------------------------------+
//| FX Sniper's T3 CCI.mq4 |
//| FX Sniper |
//| |
//+------------------------------------------------------------------+
#property copyright "FX Sniper: T3-CCI :-)"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Black
#property indicator_color2 Green
#property indicator_color3 Red
//----
extern int CCI_Period = 14;
extern int T3_Period = 4;
extern double b = 0.618;
extern bool SendMailPossible = false;

//----
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 init()
{
//---- 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);
//---- 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;
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
static datetime prevtime = 0;
int limit;
int counted_bars = IndicatorCounted();
//---- check for possible errors
if(counted_bars < 0)
return(-1);
//---- last counted bar will be recounted
if(counted_bars > 0)
counted_bars--;
limit = Bars - counted_bars;
//---- indicator calculation
for(int i = Bars - 1; i >= 0; i--)
{
cci = iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, i);
e1 = w1*cci + 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 = c1*e6 + c2*e5 + c3*e4 + c4*e3;
//----
if(cci >= 0)
cciHup = cci;
else
cciHup = 0;
//----
if(cci < 0 )
cciHdn = cci;
else
cciHdn = 0;
}

if (prevtime == Time) {
return(0);
}
else {
if((cci < 0) && (cci >= 0)) {
{
Alert(Symbol(), " M", Period(), " CCI(",CCI_Period,") crossed below zero"); PlaySound(Sound);
if (SendMailPossible) SendMail(Symbol()+ " M"+ Period()+ " CCI("+CCI_Period+") crossed above zero", "");
}
}
if((cci > 0) && (cci <= 0)) {
{
Alert(Symbol(), " M", Period(), " CCI(",CCI_Period,") crossed above zero"); PlaySound(Sound);
if (SendMailPossible) SendMail(Symbol()+ " M"+ Period()+ " CCI("+CCI_Period+") crossed above zero", "");
}
}
prevtime = Time;
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Dare2
Hi, I tryed.
Dare2
What is the methodology saying now?
timwest
This is good question ))
EN English
EN English (UK)
EN English (IN)
DE Deutsch
FR Français
ES Español
IT Italiano
PL Polski
TR Türkçe
RU Русский
PT Português
ID Bahasa Indonesia
MS Bahasa Melayu
TH ภาษาไทย
VI Tiếng Việt
JA 日本語
KO 한국어
ZH 简体中文
ZH 繁體中文
AR العربية
Home Stock Screener Forex Signal Finder Cryptocurrency Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators Website & Broker Solutions Widgets Stock Charting Library Feature Request Blog & News FAQ Help & Wiki Twitter