File Name: TrendPower.efs
Description:
Power Of Trend
Formula Parameters:
Length Fast : 4
Length Slow : 8
Notes:
Download File:
TrendPower.efs
EFS Code:
Description:
Power Of Trend
Formula Parameters:
Length Fast : 4
Length Slow : 8
Notes:
Download File:
TrendPower.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:
Power Of Trend
Version: 1.0 11/03/2009
Formula Parameters: Default:
Length Fast 4
Length Slow 8
Notes:
**********************************/
var fpArray = new Array();
var bInit = false;
function preMain(){
setPriceStudy(false);
setShowCursorLabel(false);
setShowTitleParameters(false);
setStudyTitle("Power Of Trend");
setCursorLabelName("ff", 0);
setPlotType(PLOTTYPE_HISTOGRAM, 0);
setDefaultBarFgColor(Color.lime, 0)
setDefaultBarThickness(5, 0);
setCursorLabelName("vk", 1);
setPlotType(PLOTTYPE_HISTOGRAM, 1);
setDefaultBarFgColor(Color.blue, 1);
setDefaultBarThickness(5, 1);
setCursorLabelName("vd", 2);
setPlotType(PLOTTYPE_HISTOGRAM, 2);
setDefaultBarFgColor(Color.red, 2);
setDefaultBarThickness(5, 2);
setCursorLabelName("vj", 3);
setPlotType(PLOTTYPE_HISTOGRAM, 3);
setDefaultBarFgColor(Color.green, 3);
setDefaultBarThickness(5, 3);
var x = 0;
fpArray[x] = new FunctionParameter("LengthFast", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setName("Length Fast")
setLowerLimit(1);
setDefault(4);
}
fpArray[x] = new FunctionParameter("LengthSlow", FunctionParameter.NUMBER);
with(fpArray[x++]) {
setName("Length Slow")
setLowerLimit(1);
setDefault(8);
}
}
var xMAFast = null;
var xMASlow = null;
var xVTS = null;
function main(LengthFast, LengthSlow) {
var nBarState = getBarState();
var vv = 0;
var ff = 0;
var vk = 0;
var vd = 0;
var vj = 0;
if (nBarState == BARSTATE_ALLBARS) {
if(LengthFast == null) LengthFast = 4;
if(LengthSlow == null) LengthSlow = 8;
}
if(LengthSlow <= LengthFast) LengthSlow = LengthFast + 1;
if (bInit == false) {
xMAFast = wma(LengthFast);
xMASlow = wma(LengthSlow);
xVTS = efsInternal("Calc_VTS", LengthFast, LengthSlow);
addBand(0, PS_SOLID, 1, Color.black, "Zero");
bInit = true;
}
f0 = xMAFast.getValue(0);
f1 = xMASlow.getValue(0);
vv = xVTS.getValue(0);
if (f1 == null || vv == null) return;
ff = f0 - f1;
vk = (vv + ff) / 2;
vd = (vv / 2);
vj = (ff - vd);
return new Array(ff, vk, vd, vj);
}
var bSecondInit = false;
var xOHLC4 = null;
function Calc_VTS(LengthFast, LengthSlow) {
var nRes = 0;
var i = 0;
var j = 0;
var vts = 0;
var vtsCurr = 0;
var v0 = 0;
var v1 = 0;
if (bSecondInit == false) {
xOHLC4 = ohlc4();
bSecondInit = true;
}
if (xOHLC4.getValue(-LengthSlow) == null) return;
for (i = 0; i <= LengthSlow; i++) {
vtsCurr = 0;
if (i != 0) {
for (j = 1; j <= i; j++) {
vtsCurr += xOHLC4.getValue(-j);
}
vtsCurr = vtsCurr / i;
}
vts = vts + vtsCurr;
if(i == LengthFast) v0 = vts / LengthFast;
if(i == LengthSlow) v1 = vts / LengthSlow;
}
nRes = v0 - v1;
return nRes;
}