Ergotic MDI (Mean Deviation Indicator)

ICE Data Services -

Ergotic_MDI.efs                                                                                        EFSLibrary - Discussion Board

File Name: Ergotic_MDI.efs

Description:
Ergotic MDI (Mean Deviation Indicator)

Formula Parameters:
r : 32
s : 5
u : 5

Notes:
This is one of the techniques described by William Blau in his book "Momentum,
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.

Ergotic_MDI.efs

EFS Code:

```/*********************************
Provided By:
eSignal (Copyright c eSignal), a division of Interactive Data
Formula Script (EFS) is for educational purposes only and may be
modified and saved under a new file name.  eSignal is not responsible
for the functionality once modified.  eSignal reserves the right
to modify and overwrite this EFS file with each new release.

Description:
Ergotic MDI (Mean Deviation Indicator)

Version:            1.0  01/12/2009

Formula Parameters:                     Default:
r                                   32
s                                   5
u                                   5

Notes:
This is one of the techniques described by William Blau in his book "Momentum,
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.

**********************************/

var fpArray = new Array();
var bInit = false;

function preMain() {
setStudyTitle("Ergotic_MDI (Mean Deviation Indicator)");
setCursorLabelName("ErgMDI", 0);
setCursorLabelName("SigLin", 1);
setDefaultBarFgColor(Color.fushcia, 0);
setDefaultBarFgColor(Color.grey, 1);

var x=0;
fpArray[x] = new FunctionParameter("r", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(32);
}

fpArray[x] = new FunctionParameter("s", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(5);
}

fpArray[x] = new FunctionParameter("u", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(5);
}
}

var xSignal = null;
var xEMA_R = null;
var xEMA_S = null;
var xEMA_U = null;

function main(r, s, u) {
var nState = getBarState();
var nMDI = 0;
var nSignal = 0;

if (nState == BARSTATE_ALLBARS) {
if (r == null) r = 32;
if (s == null) s = 5;
if (u == null) u = 5;
}

if ( bInit == false ) {
xEMA = ema(r);
xEMA_S = efsInternal("Calc_EMA_S", xEMA);
xEMA_U = ema(u, ema(s, xEMA_S));
xSignal = ema(u, xEMA_U);
bInit = true;
}

nMDI = xEMA_U.getValue(0);
nSignal = xSignal.getValue(0);

if (nSignal == null || nMDI == null) return;

return new Array(nMDI, nSignal);
}

function Calc_EMA_S(xEMA) {
var nRes = 0;
if (xEMA.getValue(0) == null) return;
nRes = close(0) - xEMA.getValue(0);
if (nRes == null) nRes = 1;
return nRes;
}```