Stochastic_Histogram.efs
File Name: Stochastic_Histogram.efs
Description:
Plots a histogram of the difference between the %K and %D lines.
Formula Parameters:
- nInputPercentK1: Default is 14
- nInputPercentK2: Default is 1
- nInputPercentD: Default is 3
Notes:
Default is for a "Fast Stochastic", but adjusting the nInputPercentK2 to 3 would make this a "Slow Stochastic".
Download File:
Stochastic_Histogram.efs
EFS Code:
/**************************************************************************************************** Copyright © eSignal, a division of Interactive Data Corporation. 2002. All rights reserved. This sample eSignal Formula Script (EFS) may be modified and saved under a new filename; however, eSignal is no longer responsible for the functionality once modified. eSignal reserves the right to modify and overwrite this EFS file with each new release. *****************************************************************************************************/ var study = null; function preMain() { setStudyTitle("Stochastic Histogram"); setCursorLabelName("Hist"); // Bands addBand(0, PS_SOLID, 1, Color.black); setDefaultBarFgColor(Color.black); setPlotType(PLOTTYPE_HISTOGRAM); } function main(nInputPercentK1, nInputPercentK2, nInputPercentD) { //check for valid inputs if (nInputPercentK1 == null) { nInputPercentK1 = 14; } else { nInputPercentK1 = Math.round(nInputPercentK1); } if (nInputPercentK2 == null) { nInputPercentK2 = 1; } else { nInputPercentK2 = Math.round(nInputPercentK2); } if (nInputPercentD == null) { nInputPercentD = 3; } else { nInputPercentD = Math.round(nInputPercentD); } // Create objects if first time around if (study == null) study = new StochStudy(nInputPercentK1, nInputPercentK2, nInputPercentD); var vFast = study.getValue(StochStudy.FAST); var vSlow = study.getValue(StochStudy.SLOW); var vHist = vFast - vSlow; if (vHist > 0) { setBarFgColor(Color.green); } else { setBarFgColor(Color.red); } return vHist; }