/*********************************Provided By: eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2012. 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 responsiblefor the functionality once modified. eSignal reserves the right to modify and overwrite this EFS file with each new release.Description: Applying The Sector Rotation Model by Giorgos E. SiligardosVersion: 1.00 13/06/2012Formula Parameters: Default:Roc Period 75Notes:The related article is copyrighted material. If you are not a subscriberof Stocks & Commodities, please visit www.traders.com.**********************************/var fpArray = new Array();function preMain(){ setStudyTitle("SRMind"); setPlotType(PLOTTYPE_HISTOGRAM, 0); setIntervalsBackfill(true); var x=0; fpArray[x] = new FunctionParameter("gPeriod", FunctionParameter.NUMBER); with(fpArray[x++]) { setName("Roc Period"); setLowerLimit(10); setUpperLimit(200); setDefault(75); } }var bInit = false;var bVersion = null;var xXLY = null;var xXLF = null;var xXLE = null;var xXLU = null;var xXLP = null;function main(gPeriod){ if (bVersion == null) bVersion = verify(); if (bVersion == false) return; if(!bInit) { xXLY = close(sym("XLY")); xXLF = close(sym("XLF")); xXLE = close(sym("XLE")); xXLU = close(sym("XLU")); xXLP = close(sym("XLP")); bInit = true; } var nBull01 = xXLY.getValue(0) / xXLY.getValue(-gPeriod) - 1; var nBull02 = xXLF.getValue(0) / xXLF.getValue(-gPeriod) - 1; var nBear01 = xXLE.getValue(0) / xXLE.getValue(-gPeriod) - 1; var nBear02 = xXLU.getValue(0) / xXLU.getValue(-gPeriod) - 1; var nBear03 = xXLP.getValue(0) / xXLP.getValue(-gPeriod) - 1; if (nBull01 == null || nBull02 == null || nBear01 == null || nBear02 == null || nBear03 == null) return; var nBeer = (nBear01 + nBear02 + nBear03) / 3; var nBull = (nBull01 + nBull02) / 2; var result = 100 * (nBull - nBeer); return result;}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;} |