MomIncDec.efs
EFSLibrary - Discussion Board
File Name: MomIncDec.efs
Description:
Increasing/Decreasing Momentum
Formula Parameters:
- Source: Close
- Momentum Length: 14
- Momentum SMA Length: 14
- View: All
- Line Thickness: 2
- Increasing Color: Green
- Decreasing Color: Blue
Notes:
Download File:
MomIncDec.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: Increasing/Decreasing Momentum Version: 1.0 10/29/2008 Formula Parameters: Default: Source Close Momentum Length 14 Momentum SMA Length 14 View All Line Thickness 2 Increasing Color Green Decreasing Color Blue Notes: **********************************/ var fpArray = new Array(); var bInit = false; function preMain() { setPriceStudy(true); setShowCursorLabel(false); setShowTitleParameters( false ); setStudyTitle("Increasing/Decreasing Momentum"); setColorPriceBars(true); askForInput(); var x=0; fpArray[x] = new FunctionParameter("Color1", FunctionParameter.COLOR); with(fpArray[x++]){ setName("Increasing Color"); setDefault(Color.green); } fpArray[x] = new FunctionParameter("Color2", FunctionParameter.COLOR); with(fpArray[x++]){ setName("Decreasing Color"); setDefault(Color.blue); } fpArray[x] = new FunctionParameter("MomLength", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Momentum Length"); setLowerLimit(1); setDefault(14); } fpArray[x] = new FunctionParameter("MomAvgLength", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Momentum SMA Length"); setLowerLimit(1); setDefault(14); } fpArray[x] = new FunctionParameter("Thickness", FunctionParameter.NUMBER); with(fpArray[x++]){ setName("Line Thickness"); setLowerLimit(1); setDefault(2); } fpArray[x] = new FunctionParameter("Source", FunctionParameter.STRING); with(fpArray[x++]){ setName("Source"); addOption("open"); addOption("high"); addOption("low"); addOption("close"); addOption("hl2"); addOption("hlc3"); addOption("ohlc4"); setDefault("close"); } fpArray[x] = new FunctionParameter("View", FunctionParameter.STRING); with(fpArray[x++]){ setName("View"); addOption("Increasing"); addOption("Decreasing"); addOption("All"); setDefault("All"); } } var xMomAvg = null; function main(Source, MomLength, MomAvgLength, View, Thickness, Color1, Color2) { var nMomAvg = 0; var nMomAvg1 = 0; if ( bInit == false ) { setDefaultBarThickness(Thickness, 0); xMomAvg = sma(MomAvgLength, mom(MomLength, eval(Source)())); bInit = true; } if (getCurrentBarCount() < Math.max(MomLength, MomAvgLength)) return; nMomAvg = xMomAvg.getValue(0); nMomAvg1 = xMomAvg.getValue(-1); if (nMomAvg > nMomAvg1 && (View == "Increasing" || View == "All")) { //inc setPriceBarColor(Color1); } if (nMomAvg < nMomAvg1 && (View == "Decreasing" || View == "All")) { //dec setPriceBarColor(Color2); } return; }