ElectionomicsTrader.efs
File Name: ElectionomicsTrader.efs
Description:
This study is based on the April 2007 article, Another Look at the Election Cycle, by Matt Blackman.
Formula Parameters:
NA
Notes:
The study requires a daily chart interval and eSignal version 8.0 or later. This system is a long only system and is enabled for Back Testing. The background of the chart is colored green when a long position is in force. The related article is copyrighted material. If you are not a subscriber of Active Trader Magazine, please visit www.activetradermag.com.
Download File:
ElectionomicsTrader.efs
EFS Code:
/*************************************** Provided By : eSignal (c) Copyright 2007 Description: Electionomics Trader Version 1.0 11/10/2006 Notes: * Apr 2007 Issue of Active Trader Magazine * Study requires version 8.0 or later. * Study requires a Daily chart interval. * Study is enabled for back testing. Formula Parameters: Default: N/A *****************************************************************/ function preMain() { setPriceStudy(true); setStudyTitle("Electionomics Trader "); setShowCursorLabel(false); setShowTitleParameters(false); } // Global Variables var bVersion = null; // Version flag var bInit = false; // Initialization flag var aEyear = new Array(); function main() { if (bVersion == null) bVersion = verify(); if (bVersion == false) return; if (isDaily() == false) { setStudyTitle(" !!!! Electionomics Trader study requires a Daily chart interval. !!!!!"); return; } var nState = getBarState(); var nBarYear = year(0); var sBarYear = nBarYear.toString(); var nBarMonth = month(0); var nBarDay = day(0); var bEyear = false; //Initialization if (bInit == false) { var xDate = new Date(); var nYear = xDate.getFullYear(); var nNum = 1900; var i = 0; while (nNum < nYear) { aEyear[i] = nNum; i++; nNum += 4; } bInit = true; } // buy if (Strategy.isInTrade() == false) { var sChar = sBarYear.charAt(3); if (isEyear(nBarYear) == false && (sChar == 2 || sChar == 8 || sChar == 4 || sChar == 0 || sChar == 6) && nBarMonth == 9 && nBarDay >= 20) { Strategy.doLong("Buy", Strategy.CLOSE, Strategy.THISBAR); setBarBgColor(Color.green, 0); } // sell } else if (isEyear(nBarYear) == true && nBarMonth == 11 && nBarDay >= 20) { Strategy.doSell("Sell", Strategy.CLOSE, Strategy.THISBAR); setBarBgColor(Color.red, 0); } if (Strategy.isInTrade() == true) { setBarBgColor(Color.green, 0); } return ; } function isEyear(nY) { var b = false; for (var i = 0; i < aEyear.length; i++) { if (aEyear[i] == nY) { b = true; i = aEyear.length; } } return b; } 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; }