HACO.efs
File Name: HACO.efs
Description:
Heikin-Ashi Candelstick Oscillator (HACO)
Formula Parameters:
- Long Positions Color: Lime
- Short Positions Color: Red
- Up TEMA Average Length: 34
- Down TEMA Average Length: 34
Notes:
The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.
Download File:
HACO.efs
EFS Code:
/********************************* Provided By: eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2008. 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: Heikin-Ashi Candelstick Oscillator (HACO) Version: 1.0 10/08/2008 Formula Parameters: Default: Long Positions Color Lime Short Positions Color Red Up TEMA Average Length 34 Down TEMA Average Length 34 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(); var bInit = false; var bVersion = null; function preMain() { setPriceStudy(true); setShowCursorLabel(false); setShowTitleParameters( false ); setStudyTitle("Heikin-Ashi Candelstick Oscillator"); setDefaultBarBgColor(Color.white, 0); var x=0; fpArray[x] = new FunctionParameter("UpColor", FunctionParameter.COLOR); with(fpArray[x++]){ setName("Long Positions Color"); setDefault(Color.RGB(160, 255, 160)); } fpArray[x] = new FunctionParameter("DnColor", FunctionParameter.COLOR); with(fpArray[x++]){ setName("Short Positions Color"); setDefault(Color.RGB(255,160,160)); } fpArray[x] = new FunctionParameter("Avg", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Up TEMA Average Length"); setLowerLimit(1); setDefault(34); } fpArray[x] = new FunctionParameter("Avgdn", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Down TEMA Average Length"); setLowerLimit(1); setDefault(34); } } var xhaOpen = null; var xhaC = null; var xTMA1 = null; var xTMA2 = null; var xTMA1_hl2 = null; var xTMA2_hl2 = null; var xTMA1_2 = null; var xTMA2_2 = null; var xTMA1_hl2_2 = null; var xTMA2_hl2_2 = null; var bkeeping = false; var bkeeping_Ref = false; var bkeepall = false; var bkeepall_Ref = false; var bkeeping1 = false; var bkeeping1_Ref = false; var bkeepall1 = false; var bkeepall1_Ref = false; var butr = false; var bdtr = false; var butr_Ref = false; var bdtr_Ref = false; var nhaOpen = 0; var nhaOpen_Ref = 0; var nRes = 0; var nRef = 0; function main(Avg, Avgdn, UpColor, DnColor) { var nState = getBarState(); var nhaC = 0; var nDiff = 0; var nZlDif = 0; var nZlHa = 0; var nZlCl = 0; var nTMA1 = 0; var nTMA2 = 0; var nTMA1_hl2 = 0; var nTMA2_hl2 = 0; var bkeep1 = false; var bkeep2 = false; var bkeep3 = false; var nupw = 0; var ndnw = 0; if (bVersion == null) bVersion = verify(); if (bVersion == false) return; if ( bInit == false ) { xhaOpen = efsInternal("Calc_haOpen", ohlc4()); xhaC = efsInternal("Calc_haC", ohlc4(), xhaOpen); xTMA1 = efsInternal("TEMA", xhaC, Avg); xTMA2 = efsInternal("TEMA", xTMA1, Avg); xTMA1_hl2 = efsInternal("TEMA", hl2(), Avg); xTMA2_hl2 = efsInternal("TEMA", xTMA1_hl2, Avg); xTMA1_2 = efsInternal("TEMA", xhaC, Avgdn); xTMA2_2 = efsInternal("TEMA", xTMA1_2, Avgdn); xTMA1_hl2_2 = efsInternal("TEMA", hl2(), Avgdn); xTMA2_hl2_2 = efsInternal("TEMA", xTMA1_hl2_2, Avgdn); bInit = true; } if (nState == BARSTATE_NEWBAR) { bkeeping_Ref = bkeeping; bkeepall_Ref = bkeepall; bkeeping1_Ref = bkeeping1; bkeepall1_Ref = bkeepall1; butr_Ref = butr; bdtr_Ref = bdtr; nhaOpen_Ref = nhaOpen; nRef = nRes; } nTMA1 = xTMA1.getValue(0); nTMA2 = xTMA2.getValue(0); nTMA1_hl2 = xTMA1_hl2.getValue(0); nTMA2_hl2 = xTMA2_hl2.getValue(0); nDiff = nTMA1 - nTMA2; nZlHa = nTMA1 + nDiff; nDiff = nTMA1_hl2 - nTMA2_hl2; nZlCl = nTMA1_hl2 + nDiff; nZlDif = nZlCl - nZlHa; bkeep1 = Alert1(xhaC, xhaOpen, 2); if (nZlDif >= 0) bkeep2 = true else bkeep2 = false; if (bkeep1 || bkeep2) bkeeping1 = true else bkeeping1 = false; if (bkeeping1 || (bkeeping1_Ref && (close(0) >= open(0)) || close(0) >= close(-1))) bkeepall1 = true else bkeepall1 = false; if (Math.abs(close(0) - open(0)) < (high(0) - low(0)) * 0.35 && high(0) >= low(-1)) bkeep3 = true else bkeep3 = false; if (bkeepall1 || (bkeepall1_Ref && bkeep3)) butr = true; else butr = false; nTMA1 = xTMA1_2.getValue(0); nTMA2 = xTMA2_2.getValue(0); nTMA1_hl2 = xTMA1_hl2_2.getValue(0); nTMA2_hl2 = xTMA2_hl2_2.getValue(0); nDiff = nTMA1 - nTMA2; nZlHa = nTMA1 + nDiff; nDiff = nTMA1_hl2 - nTMA2_hl2; nZlCl = nTMA1_hl2 + nDiff; nZlDif = nZlCl - nZlHa; bkeep1 = Alert2(xhaC, xhaOpen, 2); if (nZlDif < 0) bkeep2 = true else bkeep2 = false; if (Math.abs(close(0) - open(0)) < (high(0) - low(0)) * 0.35 && low(0) <= high(-1)) bkeep3 = true; else bkeep3 = false; if (bkeep1 || bkeep2) bkeeping = true; else bkeeping = false; if (bkeeping || (bkeeping_Ref && (close(0) < open(0)) || close(0) < close(-1))) bkeepall = true else bkeepall = false; if(bkeepall || (bkeepall_Ref && bkeep3) == true) bdtr = true else bdtr = false; if (bdtr == false && bdtr_Ref && butr) nupw = 1 else nupw = 0; if (butr == false && butr_Ref && bdtr) ndnw = 1 else ndnw = 0; if (nupw == 1) nRes = 1 else if(ndnw == 1) nRes = 0 else nRes = nRef; if (nRes == 1) setDefaultBarBgColor(UpColor, 0); else if (nRes == 0) setDefaultBarBgColor(DnColor, 0); return; } function Calc_haOpen(xOHLC4) { var nRes = 0; var nRef = ref(-1); if (nRef == null) nRef = 1; if (xOHLC4.getValue(-1) == null) return; nRes = (xOHLC4.getValue(-1) + nRef) / 2; if (nRes == null) return; return nRes; } function Calc_haC(xOHLC4, xhaOpen) { var nhaOpen = 0; var nRes = 0; if (xOHLC4.getValue(-1) == null) return; nhaOpen = xhaOpen.getValue(0); nRes = (xOHLC4.getValue(0) + nhaOpen + Math.max(high(0), nhaOpen) + Math.min(low(0), nhaOpen)) / 4; if (nRes == null) return; return nRes; } function Alert1(xhaC, xhaOpen, Length) { var bRes = true; for (var i = 1; i < Length; i++) { if (xhaC.getValue(-i) < xhaOpen.getValue(-i)) bRes = false; // >= } return bRes; } function Alert2(xhaC, xhaOpen, Length) { var bRes = true; for (var i = 1; i < Length; i++) { if (xhaC.getValue(-i) >= xhaOpen.getValue(-i)) bRes = false; // < } return bRes; } var xEMA1 = null; var xEMA2 = null; var xEMA3 = null; var bInitTEMA = false; function TEMA(xPrice, Length) { var nTEMA = 0; if ( bInitTEMA == false ) { xEMA1 = ema(Length, xPrice); xEMA2 = ema(Length, xEMA1); xEMA3 = ema(Length, xEMA2); bInitTEMA = true; } if (xEMA1.getValue(0) == null || xEMA2.getValue(0) == null || xEMA3.getValue(0) == null) return; nTEMA = 3 * xEMA1.getValue(0) - 3 * xEMA2.getValue(0) + xEMA3.getValue(0); return nTEMA; } 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; }