2013 Jan: The DMI Stochastic by Barbara Star

ICE Data Services -

 

DMI_Oscillator.efs, DMI_Stochastic_Extreme.efs, DMI_Stochastic_Reversal_Alerts.efs  

EFSLibrary - Discussion Board  

 

File Name: DMI_Oscillator.efs, DMI_Stochastic_Extreme.efs, DMI_Stochastic_Reversal_Alerts.efs

 

Description:
The DMI Stochastic by Barbara Star

Formula Parameters:

DMI_Oscillator.efs

  • DMI Oscillator Period: 10
  • Up Color: blue
  • Down Color: red

DMI_Stochastic_Extreme.efs

  • DMI Stochastic Period: 10
  • DMI Stochastic High/Low Period: 3
  • DMI Stochastic Sum Period: 3
  • Extreme Low Color: blue
  • Extreme Low Level: 10
  • Extreme High Color: red
  • Extreme High Level: 90


DMI_Stochastic_Reversal_Alerts.efs

  • DMI Stochastic Period: 10
  • DMI Stochastic High/Low Period: 3
  • DMI Stochastic Sum Period: 3
  • DMI Stochastic MA Period: 3
  • Below Color: green
  • Above Color: red

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

 

Download File:
DMI_Oscillator.efs
DMI_Stochastic_Extreme.efs
DMI_Stochastic_Reversal_Alerts.efs

DMI_Oscillator.efs, DMI_Stochastic_Extreme.efs, DMI_Stochastic_Reversal_Alerts.efs



EFS Code:

DMI_Oscillator.efs

/*********************************
Provided By:  
eSignal (Copyright c eSignal), a division of Interactive Data 
Corporation. 2012. 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:        
    DMI Stochastic by Barbara Star

Version:            1.00  06/07/2012

Formula Parameters:                     Default:
DMI Oscillator Period                   10
Up Color                                blue
Down Color                              red

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

**********************************/

var fpArray = new Array();

function preMain()
{   
    setStudyTitle("DMI Oscillator");    
  
    setPlotType(PLOTTYPE_HISTOGRAM, 0);    
    setColorPriceBars(true);        

    var x=0;
    
    fpArray[x] = new FunctionParameter("gPeriod", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("DMI Oscillator Period");
        setLowerLimit(1);       
        setDefault(10);
    } 
    
    fpArray[x] = new FunctionParameter("gUpColor", FunctionParameter.COLOR);
    with(fpArray[x++])
    {
        setName("Up Color");        
        setDefault(Color.blue);
    } 
    
    fpArray[x] = new FunctionParameter("gDownColor", FunctionParameter.COLOR);
    with(fpArray[x++])
    {
        setName("Down Color");        
        setDefault(Color.red);
    }
}

var bInit = false;
var bVersion = null;

var xPDI = null;
var xMDI = null;

function main(gPeriod,gUpColor,gDownColor)
{
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return; 
    
    if(!bInit)
    {
        xPDI = pdi(gPeriod,gPeriod);
        xMDI = ndi(gPeriod,gPeriod);
        
        bInit = true;
    }
    
    var vPDI = xPDI.getValue(0);
    var vMDI = xMDI.getValue(0)
    
    if (vPDI == null || vMDI == null)
        return;
    
    vDMI = vPDI-vMDI;       
    if (vDMI>0) setPriceBarColor(gUpColor); else setPriceBarColor(gDownColor);
    
    return new Array(vDMI, vDMI);    
}

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;
}


DMI_Stochastic_Extreme.efs

/*********************************
Provided By:  
eSignal (Copyright c eSignal), a division of Interactive Data 
Corporation. 2012. 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:     
    DMI Stochastic by Barbara Star

Version:            1.00  06/07/2012

Formula Parameters:                         Default:
    DMI Stochastic Period                   10
    DMI Stochastic High/Low Period          3
    DMI Stochastic Sum Period               3
    Extreme Low Color                       blue
    Extreme Low Level                       10
    Extreme High Color                      red
    Extreme High Level                      90

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

**********************************/

var fpArray = new Array();

function preMain()
{   
    setStudyTitle("DMI Stochastic Extreme");     
    
    var x = 0;
    
    fpArray[x] = new FunctionParameter("gPeriod", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("DMI Stochastic Period");
        setLowerLimit(1);        
        setDefault(10);
    } 
    
    fpArray[x] = new FunctionParameter("gHLPeriod", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("DMI Stochastic High/Low Period");
        setLowerLimit(1);        
        setDefault(3);
    } 
    
    fpArray[x] = new FunctionParameter("gSumPeriod", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("DMI Stochastic Sum Period");
        setLowerLimit(1);        
        setDefault(3);
    } 
    
    fpArray[x] = new FunctionParameter("gLowColor", FunctionParameter.COLOR);
    with(fpArray[x++])
    {
        setName("Extreme Low Color");        
        setDefault(Color.blue);
    } 
    
    fpArray[x] = new FunctionParameter("gLowExreme", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("Extreme Low Level");
        setLowerLimit(10);
        setUpperLimit(15);
        setDefault(10);
    } 
    
    fpArray[x] = new FunctionParameter("gHighColor", FunctionParameter.COLOR);
    with(fpArray[x++])
    {
        setName("Extreme High Color");        
        setDefault(Color.red);
    } 
    
    fpArray[x] = new FunctionParameter("gHighExreme", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("Extreme High Level");
        setLowerLimit(85);
        setUpperLimit(90);
        setDefault(90);
    } 
    fpArray[x] = new FunctionParameter("gShowArrows", FunctionParameter.BOOLEAN);
    with(fpArray[x++])
    {
        setName("Show Arrows");        
        setDefault(true);
    }     
}

var bInit = false;
var bVersion = null;

var xStoh = null;

function main(gPeriod, gHLPeriod, gSumPeriod, gLowColor, gLowExreme, gHighColor, gHighExreme,gShowArrows)
{
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return; 
    
    if (!bInit)
    {
        xStoh = efsInternal("GetDMI_Stohastic", gPeriod, gHLPeriod, gSumPeriod);

        bInit = true;
    }

    var vStoh_0 = xStoh.getValue(0);
    var vStoh_1 = xStoh.getValue(-1);
    
    if (vStoh_1 == null) 
        return;
    
    if (gShowArrows)
    {    
        if (vStoh_0 > gLowExreme && vStoh_1 <= gLowExreme) 
        {
            drawShapeRelative(0, gLowExreme - 5 , Shape.UPARROW, null, gLowColor, Shape.CENTER);
        } 
        
        if (vStoh_0 < gHighExreme && vStoh_1 >= gHighExreme) 
        {
            drawShapeRelative(0, gHighExreme + 5, Shape.DOWNARROW, null, gHighColor, Shape.CENTER);
        } 
    }

    return vStoh_0;
}


var bStohInit = false;

var xOsc = null;
var xHHV = null;
var xLLV = null;

function GetDMI_Stohastic(gPeriod, gHLPeriod, gSumPeriod)
{
    if(!bStohInit)
    {
        xOsc = efsInternal("GetOsc", gPeriod);        
        xHHV = hhv(gHLPeriod, xOsc);
        xLLV = llv(gHLPeriod, xOsc);
        
        bStohInit = true;
    }
    
    if(xHHV.getValue(-gSumPeriod) == null || xLLV.getValue(-gSumPeriod) == null) 
        return;

    var nSumNumerator = 0;
    var nSumDenomenator = 0;    
    
    for (var i = 0; i < gSumPeriod; i++)
    {        
        nSumNumerator   +=  xOsc.getValue(-i) - xLLV.getValue(-i);
        nSumDenomenator +=  xHHV.getValue(-i) - xLLV.getValue(-i);        
    }        

    if (nSumDenomenator == 0)
        return;
    
    var nResult = (nSumNumerator / nSumDenomenator) * 100;
    
    return nResult;    
}


var bGetOscInit = false;

var xPDI = null;
var xMDI = null;

function GetOsc(gPeriod)
{
    if(!bGetOscInit)
    {
        xPDI = pdi(gPeriod, gPeriod);
        xMDI = ndi(gPeriod, gPeriod);
        
        bGetOscInit = true;
    }
    
    var vPDI = xPDI.getValue(0);
    var vMDI = xMDI.getValue(0)
    
    if (vPDI == null || vMDI == null)
        return;
    
    var vDMI = vPDI - vMDI;
    
    return vDMI;
}

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;
}


DMI_Stochastic_Reversal_Alerts.efs

/*********************************
Provided By:  
eSignal (Copyright c eSignal), a division of Interactive Data 
Corporation. 2012. 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:       
    DMI Stochastic by Barbara Star

Version:            1.00  06/07/2012

Formula Parameters:                     Default:
DMI Stochastic Period                   10
DMI Stochastic High/Low Period          3
DMI Stochastic Sum Period               3
DMI Stochastic MA Period                3
Below Color                             green
Above Color                             red

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

**********************************/

var fpArray = new Array();

function preMain()
{   
    setStudyTitle("DMI Stochastic Reversal Alerts");
    setPriceStudy(true);           

    var x=0;
    
    fpArray[x] = new FunctionParameter("gPeriod", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("DMI_Stochastic Period");
        setLowerLimit(1);        
        setDefault(10);
    } 
    
    fpArray[x] = new FunctionParameter("gHLPeriod", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("DMI Stochastic High/Low Period");
        setLowerLimit(1);        
        setDefault(3);
    } 
    
    fpArray[x] = new FunctionParameter("gSumPeriod", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("DMI Stochastic Sum Period");
        setLowerLimit(1);
        setDefault(3);
    } 
    
    fpArray[x] = new FunctionParameter("gMAPeriod", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("DMI Stochastic MA Period");
        setLowerLimit(1);        
        setDefault(3);
    } 
    fpArray[x] = new FunctionParameter("gBelowColor", FunctionParameter.COLOR);
    with(fpArray[x++])
    {
        setName("Below Color");        
        setDefault(Color.green);
    } 
    
    fpArray[x] = new FunctionParameter("gAboveColor", FunctionParameter.COLOR);
    with(fpArray[x++])
    {
        setName("Above Color");        
        setDefault(Color.red);
    }
}


var bMainInit = false;
var bVersion = null;

var xStoh=null;
var xMA=null;

function main(gPeriod,gHLPeriod,gSumPeriod,gMAPeriod,gBelowColor,gAboveColor)
{
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return; 
      
     if(!bMainInit)
    {
        xStoh=efsInternal("GetDMI_Stohastic",gPeriod,gHLPeriod,gSumPeriod);
        xMA=sma(gMAPeriod,xStoh);
        
        bMainInit = true;
    }
    
    var vStoh_0 = xStoh.getValue(0);
    var vStoh_1 = xStoh.getValue(-1);
    
    var vMA_0 = xMA.getValue(0);
    var vMA_1 = xMA.getValue(-1);
    
    if (vStoh_1==null || vMA_1==null) return;
    
    
    if (vStoh_1 < vMA_1 && vStoh_0 > vMA_0) 
    {
        drawShapeRelative(0, BelowBar1, Shape.DIAMOND, null, gBelowColor, Shape.PRESET);
    } 
    
    if (vStoh_1 > vMA_1 && vStoh_0 < vMA_0) 
    {
        drawShapeRelative(0, AboveBar1, Shape.DIAMOND, null, gAboveColor, Shape.PRESET);
    } 
        
    return;
}

var bStohInit = false;

var xOsc = null;
var xHHV = null;
var xLLV = null;

function GetDMI_Stohastic(gPeriod, gHLPeriod, gSumPeriod)
{
    if(!bStohInit)
    {
        xOsc = efsInternal("GetOsc", gPeriod);        
        xHHV = hhv(gHLPeriod, xOsc);
        xLLV = llv(gHLPeriod, xOsc);
        
        bStohInit = true;
    }
    
    if(xHHV.getValue(-gSumPeriod) == null || xLLV.getValue(-gSumPeriod) == null) 
        return;

    var nSumNumerator = 0;
    var nSumDenomenator = 0;    
    
    for (var i = 0; i < gSumPeriod; i++)
    {        
        nSumNumerator   +=  xOsc.getValue(-i) - xLLV.getValue(-i);
        nSumDenomenator +=  xHHV.getValue(-i) - xLLV.getValue(-i);        
    }        

    if (nSumDenomenator == 0)
        return;
    
    var nResult = (nSumNumerator / nSumDenomenator) * 100;
    
    return nResult;    
}


var bGetOscInit = false;

var xPDI = null;
var xMDI = null;

function GetOsc(gPeriod)
{
    if(!bGetOscInit)
    {
        xPDI = pdi(gPeriod, gPeriod);
        xMDI = ndi(gPeriod, gPeriod);
        
        bGetOscInit = true;
    }
    
    var vPDI = xPDI.getValue(0);
    var vMDI = xMDI.getValue(0)
    
    if (vPDI == null || vMDI == null)
        return;
    
    var vDMI = vPDI - vMDI;
    
    return vDMI;
}

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;
}