File Name: FDI.efs
Description:
This study is based on the March 2007 article, Trading Systems and Fractals, by Radha Panini.
Formula Parameters:
Periods: 100
Notes:
The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.
Download File:
FDI.efs
EFS Code:
Description:
This study is based on the March 2007 article, Trading Systems and Fractals, by Radha Panini.
Formula Parameters:
Periods: 100
Notes:
The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.
Download File:
FDI.efs
EFS Code:
PHP Code:
/***************************************
Provided By : eSignal (c) Copyright 2007
Description: Trading Systems and Fractals
by Radha Panini
Version 1.0 2/22/2007
Notes:
* March 2007 Issue of Stocks and Commodities Magazine
* Study requires version 8.0 or later.
* Additional info used for calculating the Hurst exponent using the
Rescaled Range Analysis technique can be found at the following
URLs:
[url]http://www.complexity.org.au/ci/vol05/sevcik/sevcik.html[/url]
Formula Parameters: Default:
Periods 100
*****************************************/
function preMain() {
setStudyTitle("Fractal Dimension Index ");
setDefaultBarFgColor(Color.red);
setDefaultBarThickness(2);
setCursorLabelName("FDI");
addBand(1.5, PS_SOLID, 2, Color.blue, "middle");
var fp1 = new FunctionParameter("nPeriods", FunctionParameter.NUMBER);
fp1.setName("Periods");
fp1.setLowerLimit(1);
fp1.setDefault(100);
}
// Global Variables
var bVersion = null; // Version flag
var bInit = false; // Initialization flag
var xMax = null;
var xMin = null;
var nNum = 0;
var nNum_1 = 0;
function main(nPeriods) {
if (bVersion == null) bVersion = verify();
if (bVersion == false) return;
//Initialization
if (bInit == false) {
xMax = upperDonchian(nPeriods, close());
xMin = lowerDonchian(nPeriods, close());
bInit = true;
}
var nMax = xMax.getValue(0);
var nMin = xMin.getValue(0);
if (nMax == null || nMin == null) return;
var nState = getBarState();
var nFDI = 0;
var nLength = 0;
nNum_1 = 0;
for (var i = 0; i < nPeriods; i++) {
if (nMax - nMin > 0) {
nNum = (close(-i) - nMin) / (nMax - nMin);
if (i > 0) {
nLength += Math.sqrt(Math.pow((nNum - nNum_1), 2) + (1/Math.pow(nPeriods ,2)));
nNum_1 = nNum;
}
}
}
if (nLength > 0) {
nFDI = 1 + (Math.log(nLength) + Math.log(2)) / Math.log(2*nPeriods);
}
return nFDI;
}
function verify() {
var b = false;
if (getBuildNumber() < 779) {
drawTextAbsolute(5, 35, "This study requires version 8.0 or later.",
Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
null, 13, "error");
drawTextAbsolute(5, 20, "Click HERE to upgrade.@URL=http://www.esignal.com/download/default.asp",
Color.white, Color.blue, Text.RELATIVETOBOTTOM|Text.RELATIVETOLEFT|Text.BOLD|Text.LEFT,
null, 13, "upgrade");
return b;
} else {
b = true;
}
return b;
}