zzTOP.efs, zzTOPauto.efs
File Name: zzTOP.efs, zzTOPauto.efs
Description:
Filtering Price Movement by Giorgos E. Siligardos
Formula Parameters:
zzTOP.efs
- Indicator: Close
- LegsNo: 20
- Scale: A
zzTOPauto.efs
- Indicator: Close
- Proximity: 20
- Scale: A
Notes:
The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.
Download File:
zzTOP.efs
zzTOPauto.efs
zzTOPauto.efs
EFS Code:
zzTOP.efs
/********************************* Provided By: Interactive Data Corporation (Copyright В© 2015) All rights reserved. This sample eSignal Formula Script (EFS) is for educational purposes only. Interactive Data Corporation reserves the right to modify and overwrite this EFS file with each new release. Description: Filtering Price Movement by Giorgos E. Siligardos Formula Parameters: Default: Indicator Close LegsNo 20 Scale A Version: 1.00 03/11/2015 Notes: The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com. **********************************/ var fpArray = new Array(); function preMain(){ setStudyTitle("zzTOP"); setPriceStudy(true); setComputeOnClose(true); var x = 0; fpArray[x] = new FunctionParameter("fpIndicator", FunctionParameter.STRING); with(fpArray[x++]){ setName("Indicator"); addOption("Close"); addOption("Open"); addOption("High"); addOption("Low"); setDefault("Close"); } fpArray[x] = new FunctionParameter("fpLegsNo", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("LegsNo"); setLowerLimit(1); setDefault(20); } fpArray[x] = new FunctionParameter("fpScale", FunctionParameter.STRING); with(fpArray[x++]){ setName("Scale"); addOption("A"); addOption("L"); setDefault("A"); } } var bInit = false; var bVersion = null; var xSourceBase = null; var xSource = null; function main(fpIndicator, fpLegsNo, fpScale){ if (!bInit){ switch (fpIndicator){ case "Close": xSourceBase = close(); break; case "Open": xSourceBase = open(); break; case "High": xSourceBase = high(); break; case "Low": xSourceBase = low(); break; default: return; } if (fpScale == "L") xSource = efsInternal("calc_Log", xSourceBase) else xSource = xSourceBase; bInit = true; } if (getCurrentBarCount() == (getNumBars()-1)){ var nCountOfBars = getCurrentBarCount(); var nLowestInd = lowest(nCountOfBars, xSourceBase, 0); if (fpScale == "L" && nLowestInd != null && nLowestInd <= 0){ drawTextPixel( 10, 50, "A semilogarithmic scale is not supported for the negative values or 0.", Color.blue); return; } if (nLowestInd == null) return; var x1 = -(nCountOfBars - 1); var y1 = xSource.getValue(-(nCountOfBars - 1)); var aFirstBar = [x1, y1]; var x2 = 0; var y2 = xSource.getValue(0); var aLastBar = [x2, y2]; if (y1 == null || y2 == null) return; var arrayPIPs = []; arrayPIPs.push(aFirstBar); arrayPIPs.push(aLastBar); while (arrayPIPs.length < fpLegsNo + 1){ var arrayTemp = []; for (var i = 0; i < arrayPIPs.length - 1; i++){ arrayTemp.push(calc_PIP(arrayPIPs[i], arrayPIPs[i+1], xSource)) } var aMaxTempElement = arrayTemp.reduce(function(prevElemen, curElement){ return prevElemen[0] >= curElement[0] ? prevElemen : curElement }); var x = aMaxTempElement[1]; var y = xSource.getValue(aMaxTempElement[1]); if (y == null) return; arrayPIPs.push([x, y]); arrayPIPs.sort(function (element1, element2){ return element1[0] - element2[0]; }); } var tagID = 0; clearLines(); for (var i = 0; i < arrayPIPs.length - 1; i++){ x1 = arrayPIPs[i][0]; y1 = arrayPIPs[i][1]; x2 = arrayPIPs[i+1][0]; y2 = arrayPIPs[i+1][1]; if (fpScale == "L"){ y2 = Math.exp(y2); y1 = Math.exp(y1); } drawLineRelative(x1, y1, x2, y2, PS_SOLID, 2, Color.red, tagID++); } } } function calc_Log(xSource){ var nValue = xSource.getValue(0); if (nValue <= 0) return; return Math.log(nValue); } function calc_PIP(aFirstCoord, aSecondCoord, xSource){ var nIndexOfFirst = aFirstCoord[0]; var nIndexOfSecond = aSecondCoord[0]; var nCountOfBars = Math.abs(nIndexOfFirst - nIndexOfSecond) + 1; var nPrevMaxDiff = 0; var nPrevMaxIndex = 0; var aMaxValue = []; for (var i = 0; i < nCountOfBars; i++){ var nIndicatorValue = xSource.getValue(nIndexOfFirst + i); if (nIndicatorValue == null) return; var nCrossPoint = (((i * (aSecondCoord[1] - aFirstCoord[1])) / (nCountOfBars - 1)) + aFirstCoord[1]); var nDiff = Math.abs(nCrossPoint - nIndicatorValue); aMaxValue = []; aMaxValue[0] = Math.max(nDiff, nPrevMaxDiff); aMaxValue[1] = aMaxValue[0] == nDiff ? nIndexOfFirst + i : nPrevMaxIndex; nPrevMaxDiff = aMaxValue[0]; nPrevMaxIndex = aMaxValue[1]; } return aMaxValue; } 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; }
zzTOPauto.efs
/********************************* Provided By: Interactive Data Corporation (Copyright В© 2015) All rights reserved. This sample eSignal Formula Script (EFS) is for educational purposes only. Interactive Data Corporation reserves the right to modify and overwrite this EFS file with each new release. Description: Filtering Price Movement by Giorgos E. Siligardos Formula Parameters: Default: Indicator Close Proximity 20 Scale A Version: 1.00 03/11/2015 Notes: The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com. **********************************/ var fpArray = new Array(); function preMain(){ setStudyTitle("zzTOPauto"); setPriceStudy(true); setComputeOnClose(true); var x = 0; fpArray[x] = new FunctionParameter("fpIndicator", FunctionParameter.STRING); with(fpArray[x++]){ setName("Indicator"); addOption("Close"); addOption("Open"); addOption("High"); addOption("Low"); setDefault("Close"); } fpArray[x] = new FunctionParameter("fpProximity", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Proximity"); setLowerLimit(0); setUpperLimit(100); setDefault(20); } fpArray[x] = new FunctionParameter("fpScale", FunctionParameter.STRING); with(fpArray[x++]){ setName("Scale"); addOption("A"); addOption("L"); setDefault("A"); } } var bInit = false; var bVersion = null; var xSourceBase = null; var xSource = null; function main(fpIndicator, fpProximity, fpScale){ if (!bInit){ switch (fpIndicator){ case "Close": xSourceBase = close(); break; case "Open": xSourceBase = open(); break; case "High": xSourceBase = high(); break; case "Low": xSourceBase = low(); break; default: return; } if (fpScale == "L") xSource = efsInternal("calc_Log", xSourceBase) else xSource = xSourceBase; bInit = true; } if (getCurrentBarCount() == (getNumBars()-1)){ var nCountOfBars = getCurrentBarCount(); var nLowestInd = lowest(nCountOfBars, xSourceBase, 0); if (fpScale == "L" && nLowestInd != null && nLowestInd <= 0){ drawTextPixel( 10, 50, "A semilogarithmic scale is not supported for the negative values or 0.", Color.blue); return; } if (nLowestInd == null) return; var nHighest = highest(nCountOfBars, xSource, 0); var nLowest = lowest(nCountOfBars, xSource, 0); if (nHighest == null || nLowest == null) return; var nRange = nHighest - nLowest; var x1 = -(nCountOfBars - 1); var y1 = xSource.getValue(-(nCountOfBars - 1)); var aFirstBar = [x1, y1]; var x2 = 0; var y2 = xSource.getValue(0); var aLastBar = [x2, y2]; if (y1 == null || y2 == null) return; var arrayPIPs = []; arrayPIPs.push(aFirstBar); arrayPIPs.push(aLastBar); do { var arrayTemp = []; for (var i = 0; i < arrayPIPs.length - 1; i++){ arrayTemp.push(calc_PIP(arrayPIPs[i], arrayPIPs[i+1], xSource)); } var aMaxTempElement = arrayTemp.reduce(function(prevElemen, curElement){ return prevElemen[0] >= curElement[0] ? prevElemen : curElement }); if (aMaxTempElement[0] < (nRange * fpProximity / 100)) break; var x = aMaxTempElement[1]; var y = xSource.getValue(aMaxTempElement[1]); if (y == null) return; arrayPIPs.push([x, y]); arrayPIPs.sort(function (element1, element2){ return element1[0] - element2[0]; }); } while (aMaxTempElement[0] >= (nRange * fpProximity / 100)); var tagID = 0; clearLines(); for (var i = 0; i < arrayPIPs.length - 1; i++){ x1 = arrayPIPs[i][0]; y1 = arrayPIPs[i][1]; x2 = arrayPIPs[i+1][0]; y2 = arrayPIPs[i+1][1]; if (fpScale == "L"){ y2 = Math.exp(y2); y1 = Math.exp(y1); } drawLineRelative(x1, y1, x2, y2, PS_SOLID, 2, Color.red, tagID++); } } } function calc_Log(xSource){ var nValue = xSource.getValue(0); if (nValue <= 0) return; return Math.log(nValue); } function calc_PIP(aFirstCoord, aSecondCoord, xSource){ var nIndexOfFirst = aFirstCoord[0]; var nIndexOfSecond = aSecondCoord[0]; var nCountOfBars = Math.abs(nIndexOfFirst - nIndexOfSecond) + 1; var nPrevMaxDiff = 0; var nPrevMaxIndex = 0; var aMaxValue = []; for (var i = 0; i < nCountOfBars; i++){ var nIndicatorValue = xSource.getValue(nIndexOfFirst + i); if (nIndicatorValue == null) return; var nCrossPoint = (((i * (aSecondCoord[1] - aFirstCoord[1])) / (nCountOfBars - 1)) + aFirstCoord[1]); var nDiff = Math.abs(nCrossPoint - nIndicatorValue); aMaxValue = []; aMaxValue[0] = Math.max(nDiff, nPrevMaxDiff); aMaxValue[1] = aMaxValue[0] == nDiff ? nIndexOfFirst + i : nPrevMaxIndex; nPrevMaxDiff = aMaxValue[0]; nPrevMaxIndex = aMaxValue[1]; } return aMaxValue; } 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; }