eSignal_HeikinAshi.efs
EFSLibrary - Discussion Board
File Name: eSignal_HeikinAshi.efs
Description:
Based on Using The Heikin-Ashi Technique by Dan Valcu. This article appeared in the February 2004 issue of Stock & Commodities. The main formula is eSignal_HeikinAshi.efs. There are two other indicators from the article, which are also included below (eSignal_HA_OC.efs and eSignal_HADiffCO.efs).
Formula Parameters:
eSignal_HeikinAshi_v2_1.efs
- Bullish Candles (Color): lime
- Bearish Candles (Color): red
- Wick (Color): grey
- Smoothing: None
- T3 Periods: 3
- T3 V Factor: 0.5
- KAMA Periods: 2
eSignal_HA_OC.efs
- HA-Open Color: Red
- HA-Close Color: Blue
- HA-Open Thickness: 2
- HA-Close Thickness: 2
- Enable Alerts: true
- Enable Forex Conversion: false
- Forex Conversion Factor: 100000
eSignal_HADiffCO.efs
- SMA Periods: 3
- HA-DiffCO Color: Blue
- SMA HA-DiffCO Color: Red
- HA-DiffCO Thickness: 2
- SMA HA-DiffCO Thickness: 2
- Enable Alerts: true
- Enable Forex Conversion: false
- Forex Conversion Factor: 100000
Notes:
The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.
7/28/2004 - eSignal_HA_OC.efs and eSignal_HA_DiffCO.efs Versions 1.1 now include alert arrows for crosses and Edit Studies options for disabling alerts as well as Forex price conversion and the Forex conversion factor.06/29/2011 - eSignal_HeikinAshi_v1_1.efs added option to change wick color
Download File:
eSignal_HeikinAshi.efs
eSignal_HeikinAshi_v1_1.efs Version 1.1 06/29/2011
eSignal_HeikinAshi_v2_1.efs Version 2.1 07/19/2011
eSignal_HA_OC.efsVersion 1.1 7/28/2004
eSignal_HA_DiffCO.efs Version 1.1 7/28/2004
EFS Code:
/********************************* Provided By: Interactive Data Corporation (Copyright © 2010) All rights reserved. This sample eSignal Formula Script (EFS) is for educational purposes only. Interactive Data Corporation reserves the right to modify and overwrite this EFS file with each new release. Description: Heikin-Ashi with smoothing Version: 2.1 07/19/2011 Formula Parameters: Default: Bullish Candles Color.lime Bearish Candles Color.red Wick Color.grey Smoothing None T3 Periods 3 T3 V Factor 0.5 KAMA Periods 2 Notes: In version 2.1 - is deleted the limitation on visible bar quantities - add possibility to change wick color - is deleted the possibility to change efsTitle from main, because this functionality is not supported - is corrected "Division by zero" mistake for KAMA Smoothing with Period = 2 (when current and previous closes are the same) **********************************/ function preMain() { setStudyTitle("Heikin-Ashi"); setCursorLabelName("HA-High", 0); setCursorLabelName("HA-Low", 1); setCursorLabelName("HA-Open", 2); setCursorLabelName("HA-Close", 3); setDefaultBarFgColor(Color.black, 0); setDefaultBarFgColor(Color.black, 1); setDefaultBarFgColor(Color.black, 2); setDefaultBarFgColor(Color.black, 3); setPlotType(PLOTTYPE_DOT, 0); setPlotType(PLOTTYPE_DOT, 1); setPlotType(PLOTTYPE_DOT, 2); setPlotType(PLOTTYPE_DOT, 3); setDefaultBarThickness(0, 0); setDefaultBarThickness(0, 1); setDefaultBarThickness(0, 2); setDefaultBarThickness(0, 3); setShowTitleParameters(true); var fp1 = new FunctionParameter("cBull", FunctionParameter.COLOR); fp1.setName("Bullish Candles"); fp1.setDefault(Color.green); var fp2 = new FunctionParameter("cBear", FunctionParameter.COLOR); fp2.setName("Bearish Candles"); fp2.setDefault(Color.red); var fp3 = new FunctionParameter("cWick", FunctionParameter.COLOR); fp3.setName("Wick"); fp3.setDefault(Color.grey); var fp4 = new FunctionParameter("sSmooth", FunctionParameter.STRING); fp4.setName("Smoothing"); fp4.addOption("None"); fp4.addOption("T3"); fp4.addOption("KAMA"); fp4.setDefault("None"); var fp5 = new FunctionParameter("nT3Periods", FunctionParameter.NUMBER); fp5.setName("T3 Periods"); fp5.setLowerLimit(1); fp5.setDefault(3); var fp6 = new FunctionParameter("vFactor", FunctionParameter.NUMBER); fp6.setName("T3 V Factor"); fp6.setLowerLimit(0); fp6.setDefault(0.5); var fp7 = new FunctionParameter("nKAMAPeriods", FunctionParameter.NUMBER); fp7.setName("KAMA Periods"); fp7.setLowerLimit(2); fp7.setDefault(2); } var haClose = null; var haOpen = null; var haClose1 = null; var haOpen1 = null; var iCntr = 0; // T3 vars var b = null; var b2 = null; var b3 = null; var c1 = null; var c2 = null; var c3 = null; var c4 = null; var f1 = null; var f2 = null; var e1 = null; var e2 = null; var e3 = null; var e4 = null; var e5 = null; var e6 = null; var e1_1 = 0; var e2_1 = 0; var e3_1 = 0; var e4_1 = 0; var e5_1 = 0; var e6_1 = 0; var Price = null; var bInit = false; // KAMA vars var nBarCounter = 0; var aAMA = null; var aFPArray = new Array(); var bInitialized = false; var bPrimed = false; function main(cBull, cBear, cWick, sSmooth, nT3Periods, vFactor, nKAMAPeriods) { var nState = getBarState(); if (nState == BARSTATE_NEWBAR) { if ((haClose == null || haOpen == null) && close(-1) != null) { haClose = close(-1); haOpen = open(-1); } haClose1 = haClose; haOpen1 = haOpen; } if (haClose1 == null || haOpen1 == null) return; haOpen = (haOpen1 + haClose1) / 2; haClose = (open(0) + high(0) + low(0) + close(0)) / 4; if (sSmooth == "T3") haClose = T3Avg(nT3Periods, vFactor, haClose); else if (sSmooth == "KAMA") haClose = KAMA(nKAMAPeriods, haClose); if (haClose == null) return; var haHigh = Math.max(high(), haOpen, haClose); var haLow = Math.min(low(), haOpen, haClose); var vColor = Color.black; if (haClose > haOpen) vColor = cBull; if (haClose < haOpen) vColor = cBear; setBarFgColor(cWick, 0); setBarFgColor(cWick, 1); setBarFgColor(vColor, 2); setBarFgColor(vColor, 3); drawLineRelative(0, haHigh, 0, haLow, PS_SOLID, 1, cWick, "Shadow"+(iCntr++)); drawLineRelative(0, haOpen, 0, haClose, PS_SOLID, 3, vColor, "Body"+(iCntr++)); var retArray = new Array(4); retArray[0] = haHigh.toFixed(2)*1; retArray[1] = haLow.toFixed(2)*1; retArray[2] = haOpen.toFixed(2)*1; retArray[3] = haClose.toFixed(2)*1; return retArray; } //*** T3 **** var counter = 0; function T3Avg(nPeriods, vFactor, vPrice) { if (bInit == false) { b = vFactor; b2 = b * b; b3 = b * b * b; c1 = -b3; c2 = 3 * b2 + 3 * b3; c3 = -6 * b2 - 3 * b - 3 * b3; c4 = 1 + 3 * b + b3 + 3 * b2; f1 = 2 / (nPeriods + 1); f2 = 1 - f1; bInit = true; } if (getBarState() == BARSTATE_NEWBAR) { e1_1 = e1; e2_1 = e2; e3_1 = e3; e4_1 = e4; e5_1 = e5; e6_1 = e6; } e1 = f1 * vPrice + f2 * e1_1; e2 = f1 * e1 + f2 * e2_1; e3 = f1 * e2 + f2 * e3_1; e4 = f1 * e3 + f2 * e4_1; e5 = f1 * e4 + f2 * e5_1; e6 = f1 * e5 + f2 * e6_1; if ((counter++)<=nPeriods ) return null; var T3Average = c1 * e6 + c2 * e5 + c3 * e4 + c4 * e3; return T3Average; } //*** END of T3 Functions **** //*** KAMA **** function KAMA(Period, vClose) { var x; var nNoise; var nSignal; var nSmooth; if (bInitialized == false) { Period = Math.round(Period); aAMA = new Array(Period); for ( x=0; x
/********************************* Provided By : eSignal. (c) Copyright 2003 EFS Formula : Heikin-Ashi Open Close Indicator Version 1.1 7/28/2004 1.1* Added Alert Arrows on MA cross. * Added Option to disable Alerts * Added Option for Forex Price Conversion and Conversion Factor Notes: * Non-price study* Formula Parameters - HA-Open Color Default: Red - HA-Close Color Default: Blue - HA-Open Thickness Default: 2 - HA-Close Thickness Default: 2 - Enable Alerts Default: true - Enabel Forex Conversion Default: false - Forex Conversion Factor Default: 100000 *********************************/ function preMain(){ setStudyTitle("Heikin-Ashi Open Close Indicator "); setCursorLabelName("HA-Open", 0); setCursorLabelName("HA-Close", 1); setShowTitleParameters(false); var fp1 = new FunctionParameter("cOpen", FunctionParameter.COLOR); fp1.setName("HA-Open Color"); fp1.setDefault(Color.red); var fp2 = new FunctionParameter("cClose", FunctionParameter.COLOR); fp2.setName("HA-Close Color"); fp2.setDefault(Color.blue); var fp3 = new FunctionParameter("nOThickness", FunctionParameter.NUMBER); fp3.setName("HA-Open Thickness"); fp3.setLowerLimit(1); fp3.setDefault(2); var fp4 = new FunctionParameter("nCThickness", FunctionParameter.NUMBER); fp4.setName("HA-Close Thickness"); fp4.setLowerLimit(1); fp4.setDefault(2); var fp5 = new FunctionParameter("bAlerts", FunctionParameter.BOOLEAN); fp5.setName("Enable Alerts"); fp5.setDefault(true); var fp6 = new FunctionParameter("bForex", FunctionParameter.BOOLEAN); fp6.setName("Enable Forex Conversion"); fp6.setDefault(false); var fp7 = new FunctionParameter("nFactor", FunctionParameter.NUMBER); fp7.setName("Forex Conversion Factor"); fp7.setLowerLimit(1); fp7.setDefault(100000); } var haClose = null; var haOpen = null; var haClose1 = null; var haOpen1 = null; var bEdit = true; var cntr = 0; function main(cOpen, cClose, nOThickness, nCThickness, bAlerts, bForex, nFactor){ var nState = getBarState(); if (bEdit == true){ setDefaultBarFgColor(cOpen, 0); setDefaultBarFgColor(cClose, 1); setDefaultBarThickness(nOThickness, 0); setDefaultBarThickness(nCThickness, 1); bEdit = false; } if (nState == BARSTATE_NEWBAR){ cntr++; if ((haClose == null || haOpen == null) && close(-1) != null){ haClose = close(-1); haOpen = open(-1); } haClose1 = haClose; haOpen1 = haOpen; } if (haClose1 == null || haOpen1 == null) return; haOpen = (haOpen1 + haClose1) / 2; haClose = (open() + high() + low() + close()) / 4; if (bForex == false || bForex == "false") nFactor = 1; var retArray = new Array(2); retArray[0] = (haOpen * nFactor).toFixed(2) * 1; retArray[1] = (haClose * nFactor).toFixed(2) * 1; // Alerts if (haClose1 != null && haOpen1 != null && (bAlerts == true || bAlerts == "true")){ if (haClose1 < haOpen1 && haClose > haOpen) { // Up Arrow drawShapeRelative(0, haClose1 * nFactor, Shape.UPARROW, null, Color.lime, Shape.TOP | Shape.ONTOP, "arrow" + cntr); } else if (haClose1 > haOpen1 && haClose < haOpen){ // Down Arrow drawShapeRelative(0, haClose1 * nFactor, Shape.DOWNARROW, null, Color.maroon, Shape.BOTTOM | Shape.ONTOP, "arrow" + cntr); } else{ removeShape("arrow" + cntr); } } return retArray; }
//eSignal_HADiffCO.efs /********************************* Provided By : eSignal. (c) Copyright 2003 EFS Formula : Heikin-Ashi DiffCO Indicator Version 1.1 7/28/2004 1.1* Added Alert Arrows on MA cross. * Added Option to disable Alerts * Added Option for Forex Price Conversion and Conversion Factor Notes:* Non-price study* Formula Parameters - SMA Periods Default: 3 - HA-DiffCO Color Default: Blue - SMA HA-DiffCO Color Default: Red - HA-DiffCO Thickness Default: 2 - SMA HA-DiffCO Thickness Default: 2 - Enable Alerts Default: true - Enable Forex Conversion Default: false - Forex Conversion Factor Default: 100000 *********************************/ function preMain(){ setStudyTitle("Heikin-Ashi DiffCO Indicator "); setCursorLabelName("HA-DiffCO", 0); setCursorLabelName("SMA HA-DiffCO", 1); setShowTitleParameters(false); var fp0 = new FunctionParameter("nLength", FunctionParameter.NUMBER); fp0.setName("SMA Periods"); fp0.setLowerLimit(1); fp0.setDefault(3); var fp1 = new FunctionParameter("cDiffCO", FunctionParameter.COLOR); fp1.setName("HA-DiffCO Color"); fp1.setDefault(Color.blue); var fp2 = new FunctionParameter("cMADiffCO", FunctionParameter.COLOR); fp2.setName("SMA HA-DiffCO Color"); fp2.setDefault(Color.red); var fp3 = new FunctionParameter("nDThickness", FunctionParameter.NUMBER); fp3.setName("HA-DiffCO Thickness"); fp3.setLowerLimit(1); fp3.setDefault(2); var fp4 = new FunctionParameter("nMAThickness", FunctionParameter.NUMBER); fp4.setName("SMA HA-DiffCO Thickness"); fp4.setLowerLimit(1); fp4.setDefault(2); var fp5 = new FunctionParameter("bAlerts", FunctionParameter.BOOLEAN); fp5.setName("Enable Alerts"); fp5.setDefault(true); var fp6 = new FunctionParameter("bForex", FunctionParameter.BOOLEAN); fp6.setName("Enable Forex Conversion"); fp6.setDefault(false); var fp7 = new FunctionParameter("nFactor", FunctionParameter.NUMBER); fp7.setName("Forex Conversion Factor"); fp7.setLowerLimit(1); fp7.setDefault(100000); } var haClose = null; var haOpen = null; var haClose1 = null; var haOpen1 = null; var bEdit = true; var aDiffCO = null; var haDiffCO = null; var haDiffCO_1 = null; var vMA = null; var vMA_1 = null; var cntr = 0; function main(nLength, cDiffCO, cMADiffCO, nDThickness, nMAThickness, bAlerts, bForex, nFactor){ var nState = getBarState(); var i = 0; var dSum = 0; if (bEdit == true){ setDefaultBarFgColor(cDiffCO, 0); setDefaultBarFgColor(cMADiffCO, 1); setDefaultBarThickness(nDThickness, 0); setDefaultBarThickness(nMAThickness, 1); aDiffCO = new Array(nLength); bEdit = false; } if (nState == BARSTATE_NEWBAR){ cntr++; if ((haClose == null || haOpen == null) && close(-1) != null){ haClose = close(-1); haOpen = open(-1); } haClose1 = haClose; haOpen1 = haOpen; if (haDiffCO != null){ aDiffCO.pop(); aDiffCO.unshift(haDiffCO); haDiffCO_1 = haDiffCO; } vMA_1 = vMA; } if (haClose1 == null || haOpen1 == null) return; haOpen = (haOpen1 + haClose1) / 2; haClose = (open() + high() + low() + close()) / 4; haDiffCO = (haClose - haOpen); aDiffCO[0] = haDiffCO; vMA = null; if (aDiffCO[nLength - 1] != null){ for (i = 0; i < nLength; ++i) { dSum += aDiffCO[i]; } vMA = (dSum / nLength); } if (bForex == false || bForex == "false") nFactor = 1; var retArray = new Array(2); retArray[0] = (haDiffCO * nFactor).toFixed(2) * 1; retArray[1] = vMA * nFactor; // Alerts if (haDiffCO_1 != null && vMA_1 != null && (bAlerts == true || bAlerts == "true")){ if (haDiffCO_1 < vMA_1 && haDiffCO > vMA){ // Up Arrow drawShapeRelative(0, haDiffCO_1 * nFactor, Shape.UPARROW, null, Color.lime, Shape.TOP | Shape.ONTOP, "arrow" + cntr); } else if (haDiffCO_1 > vMA_1 && haDiffCO < vMA){ // Down Arrow drawShapeRelative(0, haDiffCO_1 * nFactor, Shape.DOWNARROW, null, Color.maroon, Shape.BOTTOM | Shape.ONTOP, "arrow" + cntr); } else { removeShape("arrow" + cntr); } } return retArray; }