SentimentZoneOsc.efs
File Name: SentimentZoneOsc.efs
Description:
Sentiment Zone Oscillator by Walid Khalil, MFTA, CFTe
Formula Parameters:
SentimentZoneOsc.efs
- Period: 14
- Use Dynamic Levels: true
- Dynamic Levels Period: 30
- Dynamic Levels % Range: 95
Notes:
The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com.
Download File:
SentimentZoneOsc.efs
SentimentZoneOsc.efs
EFS Code:
SentimentZoneOsc.efs
/********************************* Provided By: Interactive Data Corporation (Copyright © 2012) 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: Sentiment Zone Oscillator Version: 1.0 14/03/2012 Formula Parameters: Default: Period 14 Use Dynamic Levels true Dynamic Levels Period 30 Dynamic Levels % Range 95 Notes: The related article is copyrighted material. If you are not a subscriber of Stocks & Commodities, please visit www.traders.com. **********************************/ var OB_LEVEL = 7; var OS_LEVEL = -7; var fpArray = new Array(); function preMain() { setCursorLabelName("Sentiment Zone Osc", 0); setCursorLabelName("OverBought Level", 1); setCursorLabelName("OverSold Level", 2); setDefaultBarFgColor(Color.aqua, 0); setDefaultBarFgColor(Color.red, 1); setDefaultBarFgColor(Color.green, 2); setDefaultBarThickness(2, 0); setDefaultBarThickness(2, 1); setDefaultBarThickness(2, 2); var x=0; fpArray[x] = new FunctionParameter("gPeriod", FunctionParameter.NUMBER); with(fpArray[x++]) { setName("Period"); setLowerLimit(2); setUpperLimit(200); setDefault(14); } fpArray[x] = new FunctionParameter("gIsDynamicLevels", FunctionParameter.BOOLEAN); with(fpArray[x++]) { setName("Use Dynamic Levels"); setDefault(true); } fpArray[x] = new FunctionParameter("gExtremesPeriod", FunctionParameter.NUMBER); with(fpArray[x++]) { setName("Dynamic Levels Period"); setLowerLimit(2); setUpperLimit(200); setDefault(30); } fpArray[x] = new FunctionParameter("gPercentageRange", FunctionParameter.NUMBER); with(fpArray[x++]) { setName("Dynamic Levels % Range"); setLowerLimit(1); setUpperLimit(100); setDefault(95); } } var bInit = false; var bVersion = null; var xSZO = null; var xHLP = null; var xLLP = null; function main(gPeriod, gIsDynamicLevels, gExtremesPeriod, gPercentageRange) { if (bVersion == null) bVersion = verify(); if (bVersion == false) return; if (!bInit) { xSZO = efsInternal("calc_SZO", gPeriod); if (gIsDynamicLevels) { xHLP = hhv(gExtremesPeriod, xSZO); xLLP = llv(gExtremesPeriod, xSZO); } bInit = true; } var nOB = null; var nOS = null; if (gIsDynamicLevels) { var vHLP = xHLP.getValue(0); var vLLP = xLLP.getValue(0); if (vHLP == null || vLLP == null) return; var nRange = vHLP - vLLP; var nPRange = nRange * (gPercentageRange / 100); nOB = vLLP + nPRange; nOS = vHLP - nPRange; addBand(OB_LEVEL, PS_DASH, 1, Color.maroon, "obLevel"); addBand(OS_LEVEL, PS_DASH, 1, Color.darkgreen, "osLevel") } else { nOB = OB_LEVEL; nOS = OS_LEVEL; } var vSZO = xSZO.getValue(0); if (vSZO == null) return; return new Array(vSZO, nOB, nOS); } var bInitSZO = false; var xR = null; var xSP = null; // Sentiment Zone Oscillator function calc_SZO(period) { if (!bInitSZO) { xR = efsInternal("calc_Range"); xSP = efsInternal("TEMA", period, xR); bInitSZO = true; } var vSP = xSP.getValue(0); if (vSP == null) return; return 100 * (vSP / period); } // to include both time and sentiment function calc_Range() { var vC = close(0); var vvC = close(-1); if (vvC == null) return; if (vC > vvC) return 1; else return -1; } var bInitTEMA = false; var xEma1 = null; var xEma2 = null; var xEma3 = null; // Triple Exponential Moving Average function TEMA(period, series) { if(!bInitTEMA) { xEma1 = ema(period, series); xEma2 = ema(period, xEma1); xEma3 = ema(period, xEma2); bInitTEMA = true; } var vEma1 = xEma1.getValue(0); var vEma2 = xEma2.getValue(0); var vEma3 = xEma3.getValue(0); if (vEma3 == null) return null; return 3 * vEma1 - 3 * vEma2 + vEma3; } // verify version 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; }