/*********************************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: BOPVersion: 1.0 10/31/2008Notes:Formula Parameters: Default: Length 14 Line Color Green Line Thickness 2 Display Cursor Labels True**********************************/var fpArray = new Array();var bInit = false;function preMain() { setPriceStudy(false); setShowCursorLabel(false); setShowTitleParameters( false ); setStudyTitle("BOP"); setCursorLabelName("BOP", 0); setDefaultBarFgColor(Color.red, 0); setPlotType(PLOTTYPE_LINE, 0); setDefaultBarThickness(2, 0); askForInput(); var x=0; fpArray[x] = new FunctionParameter("LineColor", FunctionParameter.COLOR); with(fpArray[x++]){ setName("Line Color"); setDefault(Color.green); } 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(14); } fpArray[x] = new FunctionParameter("Thickness", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Line Thickness"); setLowerLimit(1); setDefault(2); }}var xBOP = null;var xAvgBOP = null;function main(Length, Thickness, LineColor, ViewValue) { if ( bInit == false ) { setDefaultBarFgColor(LineColor, 0); setDefaultBarThickness(Thickness, 0); setShowCursorLabel(ViewValue); xBOP = efsInternal("CalcBOP"); xAvgBOP = sma(Length, xBOP); bInit = true; } if (getCurrentBarCount() < Length) return; return xAvgBOP.getValue(0); }function CalcBOP() {var nRes = 0; if (high() - low(0) != 0) { nRes = (close(0) - open(0)) / (high(0) - low(0)); } if (nRes == null) nRes = 1; return nRes;} |