File Name: Vortex.efs
Description:
The Vortex Indicator
Formula Parameters:
Length of Vortex : 14
Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit www.traders.com.
Download File:
Vortex.efs
EFS Code:
Description:
The Vortex Indicator
Formula Parameters:
Length of Vortex : 14
Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit www.traders.com.
Download File:
Vortex.efs
EFS Code:
PHP Code:
/*********************************
Provided By:
eSignal (Copyright c eSignal), a division of Interactive Data
Corporation. 2009. All rights reserved. This sample eSignal
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:
The Vortex Indicator
Version: 1.01 12/29/2009
Formula Parameters: Default:
Length of Vortex 14
Notes:
The related article is copyrighted material. If you are not a subscriber
of Stocks & Commodities, please visit //www.traders.com.
**********************************/
var fpArray = new Array();
var bInit = false;
var bVersion = null;
function preMain() {
setPriceStudy(false);
setShowCursorLabel(true);
setShowTitleParameters(false);
setStudyTitle("Vortex");
setCursorLabelName("+VI", 0);
setDefaultBarFgColor(Color.blue, 0);
setPlotType(PLOTTYPE_LINE, 0);
setDefaultBarThickness(2, 0);
setCursorLabelName("-VI", 1);
setDefaultBarFgColor(Color.red, 1);
setPlotType(PLOTTYPE_LINE, 1);
setDefaultBarThickness(2, 1);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("LengthVortex", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Length of Vortex");
setLowerLimit(1);
setDefault(14);
}
}
var xVortexPlus = null;
var xVortexMinus = null;
function main(LengthVortex) {
var nBarState = getBarState();
var nVortexP = 0;
var nVortexM = 0;
if (bVersion == null) bVersion = verify();
if (bVersion == false) return;
if (nBarState == BARSTATE_ALLBARS) {
if (LengthVortex == null) LengthVortex = 14;
}
if (!bInit) {
xVortexPlus = efsInternal("Calc_Vortex", LengthVortex);
xVortexMinus = getSeries(xVortexPlus, 1);
bInit = true;
}
nVortexP = xVortexPlus.getValue(0);
nVortexM = xVortexMinus.getValue(0);
if (nVortexP == null || nVortexM == null) return;
return new Array(nVortexP, nVortexM);
}
var bSecondInit = false;
var xVMm = null;
var xVMp = null;
var xVM_TrueRange = null;
function Calc_Vortex(LengthVortex) {
var nVortexP = 0;
var nVortexM = 0;
var nVMpSum = 0;
var nVMmSum = 0;
var nTRSum = 0;
var i = 0;
if (bSecondInit == false) {
xVMp = efsInternal("Calc_VM_TR");
xVMm = getSeries(xVMp, 1);
xVM_TrueRange = getSeries(xVMp, 2);
bSecondInit = true;
}
if (xVMp.getValue(-LengthVortex) == null || xVM_TrueRange.getValue(-LengthVortex) == null) return;
for (i = LengthVortex; i >= 0; i--) {
nVMpSum += xVMp.getValue(-i);
nVMmSum += xVMm.getValue(-i);
nTRSum += xVM_TrueRange.getValue(-i);
}
if (nTRSum != 0) {
nVortexP = nVMpSum / nTRSum;
nVortexM = nVMmSum / nTRSum;
}
return new Array(nVortexP, nVortexM);
}
var bThirdInit = false;
var xHigh = null;
var xLow = null;
var xClose = null;
function Calc_VM_TR() {
var nVMp = 0;
var nVMm = 0;
var nH1 = 0;
var nH = 0;
var nL1 = 0;
var nL = 0;
var nC1 = 0;
var nTR = 0;
if (bThirdInit == false) {
xHigh = high();
xLow = low();
xClose = close();
bThirdInit = true;
}
nH1 = xHigh.getValue(-1);
nH = xHigh.getValue(0);
nL1 = xLow.getValue(-1);
nL = xLow.getValue(0);
nC1 = xClose.getValue(-1);
if (nH1 == null) return;
nVMp = Math.abs(nH - nL1);
nVMm = Math.abs(nL - nH1);
nTR = Math.max(nH - nL, Math.abs(nH - nC1));
nTR = Math.max(nTR, Math.abs(nL - nC1))
return new Array(nVMp, nVMm, nTR);
}
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;
}