2009 Mar: Second Chance Options, by Barbara Star PhD

ICE Data Services -


Pullback.efs, Arrows.efs, MAC.efs  EFSLibrary - Discussion Board
  

File Name: Pullback.efs, Arrows.efs, MAC.efs


Description:
These studies are based on the March 2009 article, Second Chance Options , by Barbara Star PhD.


Formula Parameters:
Pullback Indicators
Down Color : Green
Up Color : Red
Length Time Series MA : 5
Length EMA1 : 8
Length EMA2 : 20
Type MA for MA1 : EMA
Type MA for MA2 : EMA
Price For Time Series MA : Close
Price For EMA1 : Close
Price For EMA2 : Close

Arrows Indicator
Up arrow color : green
Down arrow color : red

MAC indicator
Use exponential moving average : true
Moving average source : close
Fast MA length : 8
Slow MA length : 20
Percent levels - absolute value : 0.5
Above zero line color : green
Below zero line color : red
Zero line color : black





Notes:
The related article is copyrighted material. If you are not
a subscriber of Stocks & Commodities, please visit www.traders.com.

Download File:
Pullback.efs
Arrows.efs
MAC.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:        	Pullback IndicatorsVersion:            1.0  03/01/2009Formula Parameters:                     Default:    Down Color                          Green    Up Color                            Red    Length Time Series MA               5    Length EMA1                         8    Length EMA2                         20    Type MA for MA1                     EMA    Type MA for MA2                     EMA    Price For Time Series MA            Close    Price For EMA1                      Close    Price For EMA2                      CloseNotes:    These studies are based on the March 2009 article, Second Chance     Options, by Barbara Star PhD.   **********************************/var fpArray = new Array();var bInit = false;function preMain() {    setPriceStudy(true);    setShowCursorLabel(false);    setShowTitleParameters( false );    setColorPriceBars(true);     setStudyTitle("Pullback Indicators");    setDefaultPriceBarColor(Color.black);           askForInput();    var x=0;    fpArray[x] = new FunctionParameter("LineColor1", FunctionParameter.COLOR);    with(fpArray[x++]){        setName("Down Color");        setDefault(Color.green);    }        fpArray[x] = new FunctionParameter("LineColor2", FunctionParameter.COLOR);    with(fpArray[x++]){        setName("Up Color");        setDefault(Color.red);    }        fpArray[x] = new FunctionParameter("Length5", FunctionParameter.NUMBER);	with(fpArray[x++]){	    setName("Length Time Series MA");        setLowerLimit(1);		        setDefault(5);    }    fpArray[x] = new FunctionParameter("Length8", FunctionParameter.NUMBER);	with(fpArray[x++]){	    setName("Length EMA1");        setLowerLimit(1);		        setDefault(8);    }    fpArray[x] = new FunctionParameter("Length20", FunctionParameter.NUMBER);	with(fpArray[x++]){	    setName("Length EMA2");        setLowerLimit(1);		        setDefault(20);    }    fpArray[x] = new FunctionParameter("Line8", FunctionParameter.STRING);	with(fpArray[x++]){	    setName("Type MA for MA1");        addOption("sma");        addOption("ema");        addOption("wma");        addOption("vwma");        setDefault("ema");    }        fpArray[x] = new FunctionParameter("Line20", FunctionParameter.STRING);	with(fpArray[x++]){  	    setName("Type MA for MA2");        addOption("sma");        addOption("ema");        addOption("wma");        addOption("vwma");        setDefault("ema");    }    	fpArray[x] = new FunctionParameter("PriceLine5", FunctionParameter.STRING);	with(fpArray[x++]){        setName("Price For Time Series MA");        addOption("open");         addOption("high");        addOption("low");        addOption("close");        addOption("hl2");        addOption("hlc3");        addOption("ohlc4");         setDefault("close");     }	fpArray[x] = new FunctionParameter("PriceLine8", FunctionParameter.STRING);	with(fpArray[x++]){        setName("Price For EMA1");        addOption("open");         addOption("high");        addOption("low");        addOption("close");        addOption("hl2");        addOption("hlc3");        addOption("ohlc4");         setDefault("close");     }	fpArray[x] = new FunctionParameter("PriceLine20", FunctionParameter.STRING);	with(fpArray[x++]){        setName("Price For EMA2");        addOption("open");         addOption("high");        addOption("low");        addOption("close");        addOption("hl2");        addOption("hlc3");        addOption("ohlc4");         setDefault("close");     }}var xMOV5 = null;var xMOV8 = null;var xMOV20 = null;function main(PriceLine5, PriceLine8, PriceLine20,  Line8, Line20, Length5, Length8, Length20, LineColor1, LineColor2) {var vSymbol;var nMOV5 = 0;var nMOV8 = 0;var nMOV20 = 0;var nMOV5_Ref = 0;    if ( bInit == false ) {         if(vSymbol == null) vSymbol = getSymbol();        xMOV5 = efsInternal("LinearReg", eval(PriceLine5)(sym(vSymbol)), Length5, 1);          xMOV8 = eval(Line8)(Length8, eval(PriceLine8)(sym(vSymbol)));              xMOV20 = eval(Line20)(Length20, eval(PriceLine20)(sym(vSymbol)));          bInit = true;     }     nMOV5 = xMOV5.getValue(0);    nMOV5_Ref = xMOV5.getValue(-1);        nMOV8 = xMOV8.getValue(0);    nMOV20 = xMOV20.getValue(-1);    if (nMOV5_Ref == null || nMOV20 == null) return;    if (nMOV8 > nMOV20 && nMOV5 <= nMOV5_Ref) {        setPriceBarColor(LineColor1);    }    if (nMOV8 < nMOV20 && nMOV5 >= nMOV5_Ref) {        setPriceBarColor(LineColor2);    }        return; }function LinearReg(xSeries, Length, TgtBar){var nRes = 0;var	nSumXY = 0;var	nSumY = 0;var	nSumX = 0;var	nSumXSqr = 0;var	nOneSixth = 1 / 6;var	nDivisor = 0;var nLRSlope = 0;var nLRAngle = 0;var nLRIntercept = 0;var nLRValue = 0;var pi = 3.1415926;var ExecOffset = 0;    if (Length > 1) {        nSumX = Length * (Length - 1) * 0.5;        nSumXSqr = Length * (Length - 1) * (2 * Length - 1) * nOneSixth ;        nDivisor = Math.pow(nSumX, 2) - Length * nSumXSqr ;        nSumXY = 0;        for (var nValue1 = 0; nValue1 < Length; nValue1++) {             nSumXY +=  nValue1 * xSeries.getValue(-nValue1);        }        nSumY = Summation(xSeries, Length);            nLRSlope = (Length * nSumXY - nSumX * nSumY) / nDivisor ;        nLRAngle = Math.atan(nLRSlope) * 180 / pi;        nLRIntercept = (nSumY - nLRSlope * nSumX) / Length ;        nLRValue = nLRIntercept + nLRSlope * (Length - 1 + ExecOffset - TgtBar) ;        nRes = nLRValue;    }     if (nRes == null) nRes = 1;    return nRes;}function Summation(xSeries, nLength){var nRes = 0;    for (var i = 0; i < nLength; i++) {           nRes += xSeries.getValue(-i);     }     if (nRes == null) nRes = 1;    return nRes;}

/*********************************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:            Arrows Indicator.Version:            1.0  03/01/2009Formula Parameters:                     Default:    Up arrow color                      green    Down arrow color                    redNotes:    Up arrow when 8 ema crosses above the 20 ema.    Down arrow when 8 ema crosses below the 20 ema.    These studies are based on the March 2009 article, Second Chance     Options , by Barbara Star PhD.   **********************************/var fpArray = new Array();var bInit = false;function preMain() {    setPriceStudy(true);    setStudyTitle("MA arrows");    setCursorLabelName("8MA", 0);    setCursorLabelName("20MA", 1);    setDefaultBarFgColor(Color.green, 0);	setDefaultBarFgColor(Color.blue, 1); 	var x = 0;	fpArray[x] = new FunctionParameter("UpColor", FunctionParameter.COLOR);    with(fpArray[x++]){        setName("Up arrow color");        setDefault(Color.green);    }      fpArray[x] = new FunctionParameter("DownColor", FunctionParameter.COLOR);    with(fpArray[x++]){        setName("Down arrow color");        setDefault(Color.red);    }   }var x8ma = null;var x20ma = null;function main(UpColor, DownColor) {var nBarCount = getCurrentBarCount();    if (UpColor == null) UpColor = Color.green;    if (DownColor == null) DownColor = Color.red;     if (bInit == false) {        x8ma = ema(8);        x20ma = ema(20);        bInit = true;    }    if (x8ma.getValue(-1) < x20ma.getValue(-1) && x8ma.getValue(0) > x20ma.getValue(0)) {        drawShapeRelative(0, BelowBar2, Shape.UPARROW, null, UpColor, Shape.PRESET, "UpArrow"+nBarCount);    } else{        removeShape("UpArrow"+nBarCount);    }    if (x8ma.getValue(-1) > x20ma.getValue(-1) && x8ma.getValue(0) < x20ma.getValue(0)) {         drawShapeRelative(0, AboveBar2, Shape.DOWNARROW, null, DownColor, Shape.PRESET, "DnArrow"+nBarCount);    } else {        removeShape("DnArrow"+nBarCount);    }        return new Array(x8ma.getValue(0), x20ma.getValue(0));}

/*********************************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:            MAC indicator.Version:            1.0  03/01/2009Formula Parameters:                     Default:    Use exponential moving average      true    Moving average source               close    Fast MA length                      8    Slow MA length                      20    Percent levels - absolute value     0.5    Above zero line color               green    Below zero line color               red    Zero line color                     blackNotes:    Price oscillator with 8 and 20 exponential moving averages is either     above (green) or below (red) its 0.5 percent levels.      If(OscP(8,20,e,% )>0.5,1,0)   vertical lines are green above the zero line    If(OscP(8,20,e,% )<-0.5,-1,0)  vertical lines are red below the zero line    Dots are plotted in black along the zero line when the indicator value is     between the +0.5  and -0.5 levels.    The values described above are defaults and can be changed.	These studies are based on the March 2009 article, Second Chance 	Options, by Barbara Star PhD.   **********************************/var fpArray = new Array();var bInit = false;function preMain() {    setPriceStudy(false);    setShowCursorLabel(true);    setShowTitleParameters( false );    setPlotType(PLOTTYPE_HISTOGRAM);    setDefaultBarThickness(1);    setStudyTitle("MAC");    setStudyMax(1);    setStudyMin(-1);    askForInput();    var x=0;    fpArray[x] = new FunctionParameter("UseExp", FunctionParameter.BOOLEAN);    with(fpArray[x++]){        setName("Use exponential moving average");        setDefault("true");    }	fpArray[x] = new FunctionParameter("MASource", FunctionParameter.STRING);	with(fpArray[x++]){        setName("Moving average source");        addOption("open");         addOption("high");        addOption("low");        addOption("close");        addOption("hl2");        addOption("hlc3");        addOption("ohlc4");         setDefault("close");     }        fpArray[x] = new FunctionParameter("LFast_MA", FunctionParameter.NUMBER);	with(fpArray[x++]){        setName("Fast MA Length");        setLowerLimit(1);		        setDefault(8);    }    fpArray[x] = new FunctionParameter("LSlow_MA", FunctionParameter.NUMBER);	with(fpArray[x++]){	    setName("Slow MA Length");        setLowerLimit(1);		        setDefault(20);    }    fpArray[x] = new FunctionParameter("Levels", FunctionParameter.NUMBER);	with(fpArray[x++]){	    setName("Percent Levels");        setLowerLimit(0.01);		        setDefault(0.5);    }    fpArray[x] = new FunctionParameter("AboveColor", FunctionParameter.COLOR);    with(fpArray[x++]){        setName("Above Zero Line color");        setDefault(Color.green);    }       fpArray[x] = new FunctionParameter("BelowColor", FunctionParameter.COLOR);    with(fpArray[x++]){        setName("Below Zero Line color");        setDefault(Color.red);    }       fpArray[x] = new FunctionParameter("ZeroColor", FunctionParameter.COLOR);    with(fpArray[x++]){        setName("Zero Line color");        setDefault(Color.black);    }}var xOsc = null;function main(UseExp, MASource, LFast_MA, LSlow_MA, Levels, AboveColor, BelowColor, ZeroColor) {    if (UseExp == null) UseExp = true;    if (MASource == null) MASource = "close";    if (LFast_MA == null) LFast_MA = 8;    if (LSlow_MA == null) LSlow_MA = 20;    if (Levels == null) Levels = 0.5;    if (AboveColor == null) AboveColor = Color.green;    if (BelowColor == null) BelowColor = Color.red;    if (ZeroColor == null) ZeroColor = Color.black;        if ( bInit == false ) {         xOsc = osc(LFast_MA, LSlow_MA, UseExp, eval(MASource)());        bInit = true;     }        var nYvalue = 0;    var drawColor = ZeroColor;    var nOsc = xOsc.getValue(0);        if (nOsc > Levels) {         nYvalue = 1;        drawColor = AboveColor;    } else if (nOsc < -Levels) {        nYvalue = -1;        drawColor = BelowColor;    }         setBarFgColor(drawColor);    return nYvalue;}