/*********************************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: Schaff Trend Version: 1.0 06/22/2009 Formula Parameters: Default: MA Short 23 MA Long 50 Cycle 10 Notes: **********************************/var fpArray = new Array();var bInit = false;function preMain(){ setPriceStudy(false); setShowCursorLabel(true); setShowTitleParameters(false); setStudyTitle("Schaff Trend"); setCursorLabelName("Schaff Trend", 0); setDefaultBarFgColor(Color.green, 0); setPlotType(PLOTTYPE_LINE, 0); setDefaultBarThickness(2, 0); setStudyMax(101); setStudyMin(-1); var x = 0; fpArray[x] = new FunctionParameter("MA_Short", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(23); } fpArray[x] = new FunctionParameter("MA_Long", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(50); } fpArray[x] = new FunctionParameter("Cycle", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(10); } }var xMACD = null;var xMACDLLV = null;var xMACDHHV = null;function main(MA_Short, MA_Long, Cycle) {var nBarState = getBarState();var nRef = ref(-1);var nMCD = 0;var smconst = 0;var nST = 0;var nLLV = 0;var nHHV = 0; if (nBarState == BARSTATE_ALLBARS) { if(MA_Short == null) MA_Short = 23; if(MA_Long == null) MA_Long = 50; if(Cycle == null) Cycle = 10; } if (bInit == false) { xMACD = macd(MA_Short, MA_Long, 1, hlc3()); xMACDLLV = lowerDonchian(Cycle, xMACD); xMACDHHV = upperDonchian(Cycle, xMACD); bInit = true; } smconst = 1 + Cycle / 2; smconst = 1 / smconst; nMCD = xMACD.getValue(0); nLLV = xMACDLLV.getValue(0); nHHV = xMACDHHV.getValue(0); if (nMCD == null || nLLV == null) return; nST = ((nMCD - nLLV) / (nHHV - nLLV)) * 100 + 0.01; nST = smconst * (nST - nRef) + nRef; return nST;} |