/*********************************Provided By: eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2010. 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: Getting Clear With Short-Term SwingsVersion: 1.00 07/13/2010Formula Parameters: Default: Line or Color Bars LineNotes: The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.**********************************/var bInit = false;var bVersion = null;function preMain() { setPriceStudy(true); setShowTitleParameters(false); setStudyTitle("Getting Clear With Short-Term Swings"); setShowCursorLabel(true, 0); setCursorLabelName("SwLine", 0); setDefaultBarFgColor(Color.cyan, 0); setPlotType(PLOTTYPE_INSTANTCOLORLINE, 0); setDefaultBarThickness(2, 0); }var upsw = 0;var xHigh = null;var xLow = null;var nHHigh = 0;var nHLow = 0;var nLHigh = 0;var nLLow = 0;function main() {var nBarState = getBarState();var nHigh = 0;var nLow = 0;var nResult = 0; if (bVersion == null) bVersion = verify(); if (bVersion == false) return; if (!bInit) { xHigh = high(); xLow = low(); nHHigh = xHigh.getValue(0); nHLow = xLow.getValue(0); nLHigh = xHigh.getValue(0); nLLow = xLow.getValue(0); bInit = true; } nHigh = xHigh.getValue(-1); nLow = xLow.getValue(-1); if (upsw == 1) { if (nHigh > nHHigh) nHHigh = nHigh; if (nLow > nHLow) nHLow = nLow; if (nHigh < nHLow && nBarState == BARSTATE_NEWBAR) { upsw = 0; nLLow = nLow; nLHigh = nHigh; } } else { if (nLow < nLLow) nLLow = nLow; if (nHigh < nLHigh) nLHigh = nHigh; if (nLow > nLHigh && nBarState == BARSTATE_NEWBAR) { upsw = 1; nHHigh = nHigh; nHLow = nLow; } } if(upsw == 1) { nResult = nHLow; setBarFgColor(Color.cyan); } if(upsw == 0) { nResult = nLHigh; setBarFgColor(Color.magenta); } if (nResult == 0) return; return nResult;}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;} |