HMA_Channels.efs EFSLibrary - Discussion Board
File Name: HMA_Channels.efs
Description:
HMA Channels
Formula Parameters:
Length : 20
Percentage : 0.5
Notes:
Download File:
HMA_Channels.efs
EFS Code:
/********************************* Provided By: eSignal (Copyright c eSignal), a division of Interactive Data Corporation. 2009. 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: HMA Channels Version: 1.0 10/29/2009 Formula Parameters: Default: Length 20 Percentage 0.5 Notes: **********************************/ var fpArray = new Array(); var bInit = false; function preMain(){ setPriceStudy(true); setShowCursorLabel(true); setShowTitleParameters(false); setStudyTitle("HMA Channels"); setCursorLabelName("Up Band", 0); setPlotType(PLOTTYPE_LINE, 0); setDefaultBarFgColor(Color.red, 0); setCursorLabelName("Dn Band", 1); setPlotType(PLOTTYPE_LINE, 1); setDefaultBarFgColor(Color.red, 1); var x = 0; fpArray[x] = new FunctionParameter("Length", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(1); setDefault(20); } fpArray[x] = new FunctionParameter("Percentage", FunctionParameter.NUMBER); with(fpArray[x++]) { setLowerLimit(0); setDefault(0.5); } } var xMAD2 = null; var xMA = null; function main(Length, Percentage) { var nBarState = getBarState(); var nUpBand = 0; var nDnBand = 0; var nMAD2 = 0; var nMA = 0; if (nBarState == BARSTATE_ALLBARS) { if(Length == null) Length = 20; if(Percentage == null) Percentage = 0.5; } if (bInit == false) { xMAD2 = wma(Math.round(Length / 2), high()); xMA = wma(Length, high()); bInit = true; } nMAD2 = xMAD2.getValue(0); nMA = xMA.getValue(0); if (nMAD2 == null || nMA == null) return; nUpBand = (1 + Percentage / 100) * nMAD2 * 2 - nMA; nDnBand = (1 - Percentage / 100) * nMAD2 * 2 - nMA; return new Array(nUpBand, nDnBand); }