File Name: StochWithDslow.efs
Description:
Stochastic study with an added %D Slow line, which is a simple moving average of the %D line.
Formula Parameters:
nKlength: 14
nKsmoothing: 1
nDlength: 15
nDsmoothing: 15
%K Color: Blue
%D Color: Red
%D Slow Color: Brown
%K Display: Off
Notes:
Version 2.0 (Updated 10/14/2004)
Notes:
- Updated parameters to use FunctionParameter Class.
- Added parameter to turn on/off display of %K, which is off by default.
- Added parameters to allow user control over study colors.
Download File:
StochWithDslow.efs
EFS Code:
Description:
Stochastic study with an added %D Slow line, which is a simple moving average of the %D line.
Formula Parameters:
nKlength: 14
nKsmoothing: 1
nDlength: 15
nDsmoothing: 15
%K Color: Blue
%D Color: Red
%D Slow Color: Brown
%K Display: Off
Notes:
Version 2.0 (Updated 10/14/2004)
Notes:
- Updated parameters to use FunctionParameter Class.
- Added parameter to turn on/off display of %K, which is off by default.
- Added parameters to allow user control over study colors.
Download File:
StochWithDslow.efs
EFS Code:
PHP Code:
/*****************************************************************
Provided By : eSignal. (c) Copyright 2003
Description: Stochastics with D Slow
Version: 2.0
2.0 Notes:
- Updated parameters to use FunctionParameter Class.
- Added parameter to turn on/off display of %K.
- Added parameters to allow user control over study colors.
*****************************************************************/
addBand(80, PS_SOLID, 2, Color.yellow, "top");
addBand(20, PS_SOLID, 2, Color.yellow, "bottom");
function preMain() {
setStudyTitle("Stochastics with D Slow ");
setStudyMin(-5);
setStudyMax(105);
setShowTitleParameters(false);
setDefaultBarFgColor(Color.blue, 0); // %K
setDefaultBarFgColor(Color.red, 1); // %D
setDefaultBarFgColor(Color.brown, 2); // %D Slow
setCursorLabelName("\%K", 0);
setCursorLabelName("\%D", 1);
setCursorLabelName("\%D Slow", 2);
var fp1 = new FunctionParameter("nKlength", FunctionParameter.NUMBER);
fp1.setName("%K Length");
fp1.setLowerLimit(1);
fp1.setDefault(14);
var fp2 = new FunctionParameter("nKsmoothing", FunctionParameter.NUMBER);
fp2.setName("%K Smoothing");
fp2.setLowerLimit(1);
fp2.setDefault(1);
var fp3 = new FunctionParameter("nDlength", FunctionParameter.NUMBER);
fp3.setName("%D Length");
fp3.setLowerLimit(1);
fp3.setDefault(15);
var fp4 = new FunctionParameter("nDsmoothing", FunctionParameter.NUMBER);
fp4.setName("%D Smoothing");
fp4.setLowerLimit(1);
fp4.setDefault(15);
var fp5 = new FunctionParameter("cK", FunctionParameter.COLOR);
fp5.setName("%K Color");
fp5.setDefault(Color.blue);
var fp6 = new FunctionParameter("cD", FunctionParameter.COLOR);
fp6.setName("%D Color");
fp6.setDefault(Color.red);
var fp7 = new FunctionParameter("cDslow", FunctionParameter.COLOR);
fp7.setName("%D Slow Color");
fp7.setDefault(Color.brown);
var fp8 = new FunctionParameter("bKdisplay", FunctionParameter.STRING);
fp8.setName("Display %K");
fp8.addOption("ON");
fp8.addOption("OFF");
fp8.setDefault("OFF");
}
var study = null;
var vDsmoothing = null;
function main(nKlength, nKsmoothing, nDlength, nDsmoothing, cK, cD, cDslow, bKdisplay) {
if (study == null) {
if (nDsmoothing == null) {
vDsmoothing = 15;
} else {
vDsmoothing = Math.abs(nDsmoothing);
}
study = new StochStudy(nKlength, nKsmoothing, nDlength);
setDefaultBarFgColor(cK, 0);
setDefaultBarFgColor(cD, 1);
setDefaultBarFgColor(cDslow, 2);
}
var vK = study.getValue(StochStudy.FAST);
if (vK == null) return;
var vD = study.getValue(StochStudy.SLOW);
if (vD == null) return;
var aD = study.getValue(StochStudy.SLOW, 0, -vDsmoothing);
if (aD == null) return;
var dSum = 0;
for (i = 0; i < vDsmoothing; ++i) {
dSum += aD[i];
}
var vDslow = (dSum/vDsmoothing);
if (bKdisplay == "OFF") vK = vK.toFixed(4);
return new Array(vK, vD, vDslow);
}