File Name: TrendContinuationFactor.efs
Description:
Trend continuation factor, by M.H. Pee
Formula Parameters:
Length : 35
Line Thickness: 2
Display Cursor Labels: True
Notes:
The related article is copyrighted material. If you are not
a subscriber of Stocks & Commodities, please visit www.traders.com.
Download File:
TrendContinuationFactor.efs
EFS Code:
Description:
Trend continuation factor, by M.H. Pee
Formula Parameters:
Length : 35
Line Thickness: 2
Display Cursor Labels: True
Notes:
The related article is copyrighted material. If you are not
a subscriber of Stocks & Commodities, please visit www.traders.com.
Download File:
TrendContinuationFactor.efs
EFS Code:
PHP Code:
/*********************************
Provided By:
eSignal (Copyright c eSignal), a division of Interactive Data
Corporation. 2008. 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:
Trend continuation factor, by M.H. Pee
Version: 1.0 12/05/2008
Formula Parameters: Default:
Length 35
Line Thickness 2
Display Cursor Labels True
Notes:
The related article is copyrighted material. If you are not
a subscriber of Stocks & Commodities, please visit [url]www.traders.com.[/url]
**********************************/
var fpArray = new Array();
var bInit = false;
var bVersion = null;
function preMain() {
setPriceStudy(false);
setShowCursorLabel(false);
setShowTitleParameters( false );
setStudyTitle("Trend Continuation Factor ");
setCursorLabelName("Zero", 0);
setCursorLabelName("Plus TCF", 1);
setCursorLabelName("Minus TCF", 2);
setDefaultBarFgColor(Color.green, 0);
setDefaultBarFgColor(Color.blue, 1);
setDefaultBarFgColor(Color.red, 2);
setPlotType(PLOTTYPE_LINE, 0);
setPlotType(PLOTTYPE_LINE, 1);
setPlotType(PLOTTYPE_LINE, 2);
setDefaultBarThickness(1, 0);
setDefaultBarThickness(1, 1);
setDefaultBarThickness(1, 2);
askForInput();
var x=0;
fpArray[x] = new FunctionParameter("ViewValue", FunctionParameter.BOOLEAN);
with(fpArray[x++]){
setName("Display Cursor Labels");
setDefault(true);
}
fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER);
with(fpArray[x++]){
setLowerLimit(1);
setDefault(35);
}
fpArray[x] = new FunctionParameter("Thickness", FunctionParameter.NUMBER);
with(fpArray[x++]){
setName("Line Thickness");
setLowerLimit(1);
setDefault(2);
}
}
var xChange = null;
var xPlusChange = null;
var xMinusChange = null;
var xPlusCF = null;
var xMinusCF = null;
function main(Length, Thickness, ViewValue) {
var nPlusTCF = 0;
var nMinusTCF = 0;
if (bVersion == null) bVersion = verify();
if (bVersion == false) return;
if ( bInit == false ) {
setDefaultBarThickness(Thickness, 0);
setDefaultBarThickness(Thickness, 1);
setDefaultBarThickness(Thickness, 2);
setShowCursorLabel(ViewValue);
setShowCursorLabel(false, 0);
xChange = efsInternal("Calc_Change");
xPlusChange = efsInternal("Calc_PlusChange", xChange);
xMinusChange = efsInternal("Calc_MinusChange", xChange);
xPlusCF = efsInternal("Calc_PlusCF", xPlusChange);
xMinusCF = efsInternal("Calc_MinusCF", xMinusChange);
bInit = true;
}
nPlusTCF = Summation( xPlusChange, xMinusCF, Length ) ;
nMinusTCF = Summation( xMinusChange, xPlusCF, Length ) ;
return new Array(0, nPlusTCF, nMinusTCF);
}
function Summation(xSeries1, xSeries2, nLength){
var nRes = 0;
for (var i = 0; i < nLength; i++) {
nRes += (xSeries1.getValue(-i) - xSeries2.getValue(-i));
}
if (nRes == null) nRes = 1;
return nRes;
}
function Calc_MinusCF(xSeries){
var nRes = 0;
var nRef = 0;
nRef = ref(-1);
if (nRef == null) nRef = 1;
if (xSeries.getValue(0) == 0) nRes = 0;
else nRes = xSeries.getValue(0) + nRef;
if (nRes == null) nRes = 1;
return nRes;
}
function Calc_PlusCF(xSeries) {
var nRes = 0;
var nRef = 0;
nRef = ref(-1);
if (nRef == null) nRef = 1;
if (xSeries.getValue(0) == 0) nRes = 0;
else nRes = xSeries.getValue(0) + nRef;
if (nRes == null) nRes = 1;
return nRes;
}
function Calc_MinusChange(xSeries) {
var nRes = 0;
if (xSeries.getValue(0) < 0) nRes = xSeries.getValue(0) * (-1);
else nRes = 0;
if (nRes == null) nRes = 1;
return nRes;
}
function Calc_PlusChange(xSeries) {
var nRes = 0;
if (xSeries.getValue(0) > 0) nRes = xSeries.getValue(0);
else nRes = 0;
if (nRes == null) nRes = 1;
return nRes;
}
function Calc_Change(){
var nRes = 0;
nRes = close(0) - close(-1);
if (nRes == null) nRes = 1;
return nRes;
}
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;
}