2005 Jan: Detecting Breakouts

ICE Data Services -


SD-ADX.efs, NormalizedStdev.efs,StochOf_NormStdev.efs, VolatilityModifiedFVE2.efs   EFSLibrary - Discussion Board
  

File Name: SD-ADX.efs, NormalizedStdev.efs, StochOf_NormStdev.efs,VolatilityModifiedFVE2.efs


Description:
These indicators are based on the January 2005 article, Detecting Breakouts in Low-Priced Stocks: Los Vegas Or Los Nasdaq?, by Markos Katsanos.


Formula Parameters:
SD-ADX.efs
Period for SD: 30
Period for ADX: 25
Color: Magenta
Thickness: 2

NormalizedStdev.efs
Length: 30
Color: Aqua
Thickness: 2

StochOf_NormStdev.efs
Normalized Stdev Period: 30
Stoch \%K Length: 150
Stoch \%K Smoothing: 1
Stoch \%D Length: 10
Upper Band: 80
Lower Band: 20
Band's Color: Black
Display Bands: True - [True, False]
%K Color: Red
%K Thickness: 2
%D Color: Blue
%D Thickness: 1
%D Display: Off - [On, Off]

VolatilityModifiedFVE2.efs
Periods for FVE: 14
EMA Periods for FVE: 40
Coef for Cutoff: 0.1
FVE Color: Green
FVE Thickness: 2
FVE EMA Color: Blue
FVE EMA Thickness: 1
EMA Display: Off - [On, Off]

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

Download File:
SD-ADX.efs
NormalizedStdev.efs
StochOf_NormStdev.efs
VolatilityModifiedFVE2.efs







EFS Code:












/*****************************************************************Provided By : eSignal (c) Copyright 2004Description:  SD*Adx - by Markos Katsanos from Detecting BreakoutsVersion 1.0Notes:Formula Parameters:                 Defaults:Period for SD                       30Period for ADX                      25Color                               magentaThickness                           2*****************************************************************/function preMain() {    setStudyTitle("SD*Adx ");    setCursorLabelName("SD*Adx");    setDefaultBarThickness(2);    addBand(1.3, PS_SOLID, 1, Color.navy, "band");    setShowTitleParameters(false);        // Formula Parameters    var fp1 = new FunctionParameter("nPeriod", FunctionParameter.NUMBER);        fp1.setName("Period for SD");        fp1.setLowerLimit(5);        fp1.setUpperLimit(80);        fp1.setDefault(30);    var fp2 = new FunctionParameter("nDI", FunctionParameter.NUMBER);        fp2.setName("Period for ADX");        fp2.setLowerLimit(5);        fp2.setUpperLimit(80);        fp2.setDefault(25);    // Study Parameters    var sp1 = new FunctionParameter("cColor", FunctionParameter.COLOR);        sp1.setName("Color");        sp1.setDefault(Color.magenta);    var sp2 = new FunctionParameter("nThick", FunctionParameter.NUMBER);        sp2.setName("Thickness");        sp2.setDefault(2);}var bEdit = true;var aPrice = null;var vStudyMA = null;var vStudyADX = null;var nC = null;function main(nPeriod, nDI, cColor, nThick) {    if (bEdit == true) {        aPrice = new Array(nPeriod);        vStudyMA = new MAStudy(nPeriod, 0, "Close", MAStudy.SIMPLE);        vStudyADX = new ADXDMStudy(nDI, nDI);        setDefaultBarFgColor(cColor, 0);        setDefaultBarThickness(nThick, 0);        bEdit = false;    }        var nState = getBarState();    if (nState == BARSTATE_NEWBAR && nC != null) {        aPrice.pop();        aPrice.unshift(nC);    }    nC = close(0);    aPrice[0] = nC;            var vMA = vStudyMA.getValue(MAStudy.MA);    if (vMA == null) return;        var vADX = vStudyADX.getValue(ADXDMStudy.ADX);    if (vADX == null) return;        if (aPrice[nPeriod-1] == null) return;  // array not complete        var nSD = Stdev(nPeriod);    var nSDC = (nSD/vMA);        return (nSDC*vADX);}// Support Functionsfunction Stdev(nLength) {    var sumX = 0;    var sumX2 = 0;    for (i = 0; i < nLength; ++i) {        sumX += aPrice[i];        sumX2 += (aPrice[i] * aPrice[i]);    }    var meanX = (sumX/nLength);    var stdev = Math.sqrt((sumX2/nLength) - (meanX*meanX));    return stdev;}/*****************************************************************Provided By : eSignal (c) Copyright 2004Description: Normalized Standard Deviation - Markos KatsanosVersion 1.0Notes:Formula Parameters:                     Defaults:Length                                  30Color                                   aquaThickness                               2*****************************************************************/function preMain() {    setStudyTitle("Normalized Standard Deviation ");    setCursorLabelName("N-Stdev",0);        // Formula Parameters    var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);        fp1.setName("Period");        fp1.setLowerLimit(1);		        fp1.setDefault(30);    // Study Parameters    var sp1 = new FunctionParameter("cColor", FunctionParameter.COLOR);        sp1.setName("Color");        sp1.setDefault(Color.aqua);    var sp2 = new FunctionParameter("nThick", FunctionParameter.NUMBER);        sp2.setName("Thickness");        sp2.setDefault(2);} var bEdit = true;var aValue = null;var vStudy = null;function main(Length, cColor, nThick) {    if (bEdit == true) {        setDefaultBarFgColor(cColor, 0);        setDefaultBarThickness(nThick, 0);        bEdit = false;    }        if (aValue == null) aValue = new Array(Length);    if (vStudy == null) vStudy = new MAStudy(Length, 0, "Close", MAStudy.SIMPLE);        var nMA = vStudy.getValue(MAStudy.MA);    if (nMA == null) return;        var nState = getBarState();    var nSum = 0;    var ySum = 0;    var Basis = 0;    var vStdDev = 0;        if (nState == BARSTATE_NEWBAR) {        aValue.pop();        aValue.unshift(close(0));    }        aValue[0] = close(0);        if (aValue[Length-1] == null) return;        for(i = 0; i < Length; i++){        nSum += (aValue[i]);    }    Basis=nSum/Length;        for(i = 0; i < Length; i++){        ySum += (aValue[i]-Basis)*(aValue[i]-Basis);    }    vStdDev=Math.sqrt(ySum/(Length));     return (vStdDev/nMA);}/*****************************************************************Provided By : eSignal. (c) Copyright 2004Description:  Stochastic of Normalized Standard Deviation - Markos KatsanosVersion 1.0Notes:Formula Parameters:                 Defaults:Normalized Stdev Period             30Stoch \%K Length                    150Stoch \%K Smoothing                 1Stoch \%D Length                    10Upper Band                          80Lower Band                          20Band's Color                        blackDisplay Bands                       True - [True, False]%K Color                            red%K Thickness                        2%D Color                            blue%D Thickness                        1%D Display                          Off - [On, Off]*****************************************************************/function preMain() {    setStudyTitle("Stochastic of Normalized Stdev");    setCursorLabelName("Stoch of SD \%K", 0);    setCursorLabelName("Stoch of SD \%D", 1);    setDefaultBarFgColor(Color.navy, 0);    setDefaultBarFgColor(Color.aqua, 1);        setStudyMax(120);    setStudyMin(-5);        // Primary Study Parameters    var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);        fp1.setName("Normalized Stdev Period");        fp1.setLowerLimit(1);		        fp1.setDefault(30);    // Stoch Parameters    var fp2 = new FunctionParameter("nKlength2", FunctionParameter.NUMBER);        fp2.setName("Stoch \%K Length");        fp2.setLowerLimit(1);        fp2.setDefault(150);    var fp3 = new FunctionParameter("nKsmooth2", FunctionParameter.NUMBER);        fp3.setName("Stoch \%K Smoothing");        fp3.setLowerLimit(1);        fp3.setDefault(1);    var fp4 = new FunctionParameter("nDlength2", FunctionParameter.NUMBER);        fp4.setName("Stoch \%D Length");        fp4.setLowerLimit(1);        fp4.setDefault(10);    // Study Parameters    var sp1 = new FunctionParameter("nBand1", FunctionParameter.NUMBER);        sp1.setName("Upper Band");        sp1.setDefault(80);    var sp2 = new FunctionParameter("nBand2", FunctionParameter.NUMBER);        sp2.setName("Lower Band");        sp2.setDefault(20);    var sp3 = new FunctionParameter("cBands", FunctionParameter.COLOR);        sp3.setName("Band's Color");        sp3.setDefault(Color.black);      var sp4 = new FunctionParameter("bBands", FunctionParameter.STRING);        sp4.setName("Display Bands");        sp4.addOption("On");        sp4.addOption("Off");        sp4.setDefault("On");       var sp5 = new FunctionParameter("cK", FunctionParameter.COLOR);        sp5.setName("\%K Color");        sp5.setDefault(Color.red);    var sp6 = new FunctionParameter("nThickK", FunctionParameter.NUMBER);        sp6.setName("\%K Thickness");        sp6.setDefault(2);    var sp7 = new FunctionParameter("cD", FunctionParameter.COLOR);        sp7.setName("\%D Color");        sp7.setDefault(Color.blue);    var sp8 = new FunctionParameter("nThickD", FunctionParameter.NUMBER);        sp8.setName("\%D Thickness");        sp8.setDefault(1);    var sp9 = new FunctionParameter("bD", FunctionParameter.STRING);        sp9.setName("\%D Display");        sp9.addOption("On");        sp9.addOption("Off");        sp9.setDefault("Off");}// Primary Study: Normalized Stdevvar aNormStdev = null;var aValue = null;var vStudy = null;// Stoch of Primary Studyvar bEdit = true;var study = null;var vK2 = null;     var vD2 = null;var aStochK2 = null;function main(Length, nKlength2, nKsmooth2, nDlength2, nBand1, nBand2,             cBands, bBands, cK, nThickK, cD, nThickD, bD) {    var nState = getBarState();        if (bEdit == true) {        if (bBands == "On") {            addBand(nBand1, PS_SOLID, 1, cBands, "Upper");            addBand(nBand2, PS_SOLID, 1, cBands, "Lower");        } else if (bBands == "Off") {            removeBand("Upper");            removeBand("Lower");        }        setDefaultBarFgColor(cK, 0);        setDefaultBarFgColor(cD, 1);        setDefaultBarThickness(nThickK, 0);        setDefaultBarThickness(nThickD, 1);        if (aStochK2 == null) aStochK2 = new Array(Math.round(nDlength2));        bEdit = false;    }    if (nState == BARSTATE_NEWBAR) {        if (vK2 != null) {            aStochK2.pop();            aStochK2.unshift(vK2);        }    }        //primary study code: Stoch of Normalized Stdev    if (aNormStdev == null) aNormStdev = new Array(nKlength2);    if (aValue == null) aValue = new Array(Length);    if (vStudy == null) vStudy = new MAStudy(Length, 0, "Close", MAStudy.SIMPLE);        var nMA = vStudy.getValue(MAStudy.MA);    if (nMA == null) return;        var nSum = 0;    var ySum = 0;    var Basis = 0;    var vStdDev = 0;        if (nState == BARSTATE_NEWBAR) {        aValue.pop();        aValue.unshift(close(0));        aNormStdev.pop();        aNormStdev.unshift(0);    }        aValue[0] = close(0);        if (aValue[Length-1] == null) return;        for(i = 0; i < Length; i++){        nSum += (aValue[i]);    }    Basis=nSum/Length;        for(i = 0; i < Length; i++){        ySum += (aValue[i]-Basis)*(aValue[i]-Basis);    }    vStdDev = (Math.sqrt(ySum/(Length)))/nMA;     aNormStdev[0] = vStdDev;        // end of primary study code        // Stoch of Normalized Stdev    vK2 = StochK2(Math.round(nKlength2), Math.round(nKsmooth2));    if (vK2 == null) return;    aStochK2[0] = vK2;        if (aStochK2[Math.round(nDlength2) - 1] == null) return;        vD2 = StochD2(Math.round(nDlength2));    if (vD2 == null) return;        if (bD == "On") {        return new Array(vK2, vD2);    } else {        return new Array(vK2, vD2.toFixed(4));    }}/*********************//***** Functions *****//*********************/function StochHH(nInputOffset, nInputLength) {    var nOffset = nInputOffset;    var nLength = nInputLength;    var hh = 0;    var i = 0;        for(i = 0; i < nLength; i++) {        if(i == 0) {            hh = aNormStdev[i+nOffset];        } else {            hh = Math.max(hh, aNormStdev[i+nOffset]);        }    }    return hh;}function StochLL(nInputOffset, nInputLength) {    var nOffset = nInputOffset;    var nLength = nInputLength;    var ll = 0;    var i = 0;        for(i = 0; i < nLength; i++) {        if(i == 0) {            ll = aNormStdev[i+nOffset];        } else {            ll = Math.min(ll, aNormStdev[i+nOffset]);        }    }    return ll;}function StochK2(inputLength, inputSmoothing) {    var percentK;    var StochK;    var ll, hh;    var sum = 0;    var i = 0;    var nOffset = 0;    var nDO;    var nLength = inputLength;    var nSmoothing = inputSmoothing;    for(i = 0; i < nSmoothing; i++) {        nDO = i + nOffset;        StochK = aNormStdev[nDO];                ll = StochLL(nDO, nLength);        if(ll == null) return null;                hh = StochHH(nDO, nLength);        if(hh == null) return null;                percentK = ((StochK - ll) / (hh - ll)) * 100;                sum += percentK;    }    sum /= nSmoothing;    return sum;}function StochD2(nInputLength) {    var sum = 0;    var i = 0;    for (i = 0; i < nInputLength; ++i) {        sum += aStochK2[i];    }    sum /= nInputLength;    return sum;}/*******************************************************************Description	: This Indicator plots the Volatility modified FVE formulaProvided By	: TS Support, LLC for eSignalVersion 2.0Notes:* Original formula code has been modified by eSignal for     real time calculations and additional parameters. 11/8/2004Formula Parameters:                 Defaults:Periods for FVE                     14EMA Periods for FVE                 40Coef for Cutoff                     0.1FVE Color                           greenFVE Thickness                       2FVE EMA Color                       blueFVE EMA Thickness                   1EMA Display                         Off - [On, Off]********************************************************************/function preMain(){    setStudyTitle("Volatility Finite Volume Elements2");    setCursorLabelName("FVE",0);    setDefaultBarFgColor(Color.green,0);    setCursorLabelName("FVE EMA",1);    setDefaultBarFgColor(Color.blue,1);    setDefaultBarThickness(2);    addBand(0, PS_SOLID, 2, Color.black);    setShowTitleParameters(false);        // Formula Parameters    var fp1 = new FunctionParameter("Samples", FunctionParameter.NUMBER);        fp1.setName("Periods for FVE");        fp1.setLowerLimit(5);        fp1.setDefault(14);    var fp2 = new FunctionParameter("Perma", FunctionParameter.NUMBER);        fp2.setName("EMA Periods for FVE");        fp2.setLowerLimit(1);        fp2.setDefault(40);    var fp3 = new FunctionParameter("Coef", FunctionParameter.NUMBER);        fp3.setName("Coef for Cutoff");        fp3.setLowerLimit(0);        fp3.setDefault(.1);        // Study Parameters    var sp1 = new FunctionParameter("cFVE", FunctionParameter.COLOR);        sp1.setName("FVE Color");        sp1.setDefault(Color.green);    var sp2 = new FunctionParameter("nThickFVE", FunctionParameter.NUMBER);        sp2.setName("FVE Thickness");        sp2.setDefault(2);    var sp3 = new FunctionParameter("cEMA", FunctionParameter.COLOR);        sp3.setName("FVE EMA Color");        sp3.setDefault(Color.blue);    var sp4 = new FunctionParameter("nThickEMA", FunctionParameter.NUMBER);        sp4.setName("FVE EMA Thickness");        sp4.setDefault(1);    var sp5 = new FunctionParameter("bEMA", FunctionParameter.STRING);        sp5.setName("EMA Display");        sp5.addOption("On");        sp5.addOption("Off");        sp5.setDefault("Off");}var bEdit = true;var EMA_1 = 0;var EMA = 0;var VolumePlusMinusArray = null;var	IntraArray = null;var InterArray = null;var TP = 0;var TP1 = 0;function main(Samples, Perma, Coef, cFVE, nThickFVE, cEMA, nThickEMA, bEMA) {    if (bEdit == true) {        setDefaultBarFgColor(cFVE, 0);        setDefaultBarFgColor(cEMA, 1);        setDefaultBarThickness(nThickFVE, 0);        setDefaultBarThickness(nThickEMA, 1);        bEdit = false;    }	var VolumePlusMinus = 0, FVE = 0, Fvesum = 0,         VolSum = 0, FveFactor = 0, Intra = 0, Inter = 0, Vintra = 0,         Vinter = 0, CutOff = 0, i = 0, K = 2 / (Perma + 1);    var nState = getBarState();		if (IntraArray == null) IntraArray = new Array(Samples);	if (InterArray == null) InterArray = new Array(Samples);	if (VolumePlusMinusArray == null) VolumePlusMinusArray = new Array(Samples);		if (nState == BARSTATE_NEWBAR) {        IntraArray.pop();        IntraArray.unshift(0);        InterArray.pop();        InterArray.unshift(0);        VolumePlusMinusArray.pop();        VolumePlusMinusArray.unshift(0);        TP1 = TP;	}		IntraArray[0] = Math.log(high(0)) - Math.log(low(0));	InterArray[0] = Math.log((high(0) + low(0) + close(0))/3) -         Math.log((high(-1)+ low(-1) + close(-1))/3);		TP = (high(0) + low(0) + close(0))/3;		if (IntraArray[Samples -1] == null) return;	if (InterArray[Samples -1] == null) return;		Intra = Math.log(high(0)) - Math.log(low(0));	Vintra = StandardDev(IntraArray, Samples);	Inter = Math.log(TP) - Math.log(TP1);	Vinter = StandardDev(InterArray, Samples);	CutOff = Coef * (Vintra + Vinter) * close(0);		MF = close(0) - ((high(0) + low(0))/2) + TP - TP1;		if(MF > CutOff)		FveFactor = 1;	else if(MF < -1 * CutOff)		FveFactor = -1;	else		FveFactor=0;		VolumePlusMinus = volume(0) * FveFactor;    VolumePlusMinusArray[0] = VolumePlusMinus;    if (VolumePlusMinusArray[Samples-1] == null) return;	for(i = 0; i < Samples; i++){		Fvesum += VolumePlusMinusArray[i];		VolSum += volume(-i);	}		if(VolumePlusMinusArray[Samples - 1] != null){		FVE = (Fvesum / (VolSum/Samples)) / Samples * 100;		if (nState == BARSTATE_NEWBAR) EMA_1 = EMA;		EMA = K * FVE  + (1 - K) * EMA_1;		if (bEMA == "On") {            return new Array(FVE,EMA);        } else {            return new Array(FVE,EMA.toFixed(4));        }	}	return null;}function StandardDev(Array,Length){	var i;	var vSum = 0;	var SumSqr = 0;	var StdDev = 0;		for(i = 0; i < Length; i++)        	vSum += Array[i];	if(Length != 0)		for(i = 0; i < Length; i++)			SumSqr += (Array[i] - vSum / Length) * (Array[i] - vSum / Length);	StdDev = Math.sqrt(SumSqr / Length);	return StdDev;}