/******************************************************************** Title: Hull MA Script for eSignal 7.x By: Chris D. Kryza (Divergence Software, Inc.) Email: ckryza@verizon.net; ckryza@sr-analyst.com Incept: 01/13/2006 Version: 1.0.0 ===================================================================== Fix History: 01/13/2006 - Initial Release 1.0.0 ===================================================================== Project Description: Hull Moving Average. Dislaimer: For educational purposes only! Obviously, no guarantees whatsoever and use at your own risk. **********************************************************************/ //External Variables var nBarCounter = 0; var nStudy1 = null; var nStudy2 = null; var nPlot = null; var nPlot_1 = null; var aFPArray = new Array(); var bInitialized = false; //== PreMain function required by eSignal to set things up function preMain() { var x; setPriceStudy(true); setStudyTitle("Hull MA"); setCursorLabelName("HullMA", 0); setDefaultBarFgColor( Color.blue, 0 ); setShowTitleParameters( false ); //initialize formula parameters x=0; aFPArray[x] = new FunctionParameter( "Period", FunctionParameter.NUMBER); with( aFPArray[x] ) { setName( "Hull MA Period" ); setLowerLimit( 2 ); setUpperLimit( 9999 ); setDefault( 15 ); } x++; aFPArray[x] = new FunctionParameter( "Price", FunctionParameter.STRING); with( aFPArray[x] ) { setName( "Hull MA Price Source" ); addOption( "close" ); addOption( "open" ); addOption( "high" ); addOption( "low" ); addOption( "hl2" ); addOption( "hlc3" ); addOption( "ohlc4" ); setDefault( "close" ); } x++; aFPArray[x] = new FunctionParameter( "UpColor", FunctionParameter.COLOR); with( aFPArray[x] ) { setName( "Up Color" ); setDefault( Color.green ); } x++; aFPArray[x] = new FunctionParameter( "DnColor", FunctionParameter.COLOR); with( aFPArray[x] ) { setName( "Dn Color" ); setDefault( Color.red ); } x++; aFPArray[x] = new FunctionParameter( "Type", FunctionParameter.STRING); with( aFPArray[x] ) { setName( "Plot Type" ); addOption( "Solid" ); addOption( "Dot" ); addOption( "Dash" ); addOption( "DashDot" ); addOption( "DashDotDot" ); setDefault( "Solid" ); } x++; aFPArray[x] = new FunctionParameter( "Thickness", FunctionParameter.NUMBER); with( aFPArray[x] ) { setName( "Plot Thickness" ); setLowerLimit( 1 ); setUpperLimit( 10 ); setDefault( 3 ); } } //== Main processing function function main( Period, Price, UpColor, DnColor, Type, Thickness ) { var x; //script is initializing if ( getBarState() == BARSTATE_ALLBARS ) { return null; } if ( bInitialized == false ) { setDefaultBarThickness( Math.round( Thickness ), 0 ); setDefaultBarStyle( eval( "PS_"+Type.toUpperCase() ), 0 ); nSrc = eval( Price )(); nStudy1 = efsInternal( "custSeriesFunc", Period, nSrc ); nStudy2 = wma( Math.floor( Math.sqrt( Period ) ), nStudy1 ); bInitialized = true; } //called on each new bar if ( getBarState() == BARSTATE_NEWBAR ) { nPlot_1 = nPlot; nBarCounter++; } nPlot = nStudy2.getValue(0); if ( nPlot>nPlot_1 ) { setBarFgColor( UpColor, 0 ); setDefaultBarFgColor( UpColor, 0 ); } if ( nPlot