/*********************************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: A Seasonal Strategy With Leveraged ETFs by Gerald GardnerVersion: 1.00 13/08/2012Formula Parameters: Default:Buy Color limeSell Color redNotes: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("HalloweenIndicator"); setPriceStudy(true); var x=0; fpArray[x] = new FunctionParameter("gBuyColor", FunctionParameter.COLOR); with(fpArray[x++]) { setName("Buy Color"); setDefault(Color.lime); } fpArray[x] = new FunctionParameter("gSellColor", FunctionParameter.COLOR); with(fpArray[x++]) { setName("Sell Color"); setDefault(Color.red); } }var bInit = false;var bVersion = null;var xClose = null;var xSMA = null;var xMonth = null;function main(gBuyColor,gSellColor){ if (bVersion == null) bVersion = verify(); if (bVersion == false) return; if(!bInit) { xClose = close(); xSMA = sma(50); xMonth = getMonth(); bInit = true; } var vClose = xClose.getValue(0); var vSMA = xSMA.getValue(0); var vMonth = xMonth.getValue(0); if ((vClose == null) || (vSMA == null) || (vMonth == null)) return; // Back Testing formulas are not for real time analysis. // Therefore, prevent processing and exit at bar 0. if (getCurrentBarIndex() != 0) { var bLStrategy = Strategy.isLong(); if (vMonth==10) { if ((vClose > vSMA) && (!bLStrategy)) { Strategy.doLong("Enter Long", Strategy.MARKET, Strategy.NEXTBAR); drawTextRelative(1, BelowBar1, "Long", Color.black, gBuyColor, Text.PRESET, null, null); } } if ((vMonth==5) && (bLStrategy)) { Strategy.doSell("Exit Long", Strategy.MARKET, Strategy.NEXTBAR); drawTextRelative(1, AboveBar1, "Exit Long", Color.black, gSellColor, Text.PRESET, null, null); } } return vSMA;}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;} |