2014 July (Apr): Evidence-Based Support & Resistance by Melvin E. Dickover

ICE Data Services -

RelativeVolume.efs, FreedomOfMovement.efs  

EFSLibrary - Discussion Board  

 

File Name: RelativeVolume.efs, FreedomOfMovement.efs

 

Description:
Evidence-Based Support & Resistance by Melvin E. Dickover

 

Formula Parameters:

RelativeVolume.efs

  • Period: 60
  • StDevs: 2

FreedomOfMovement.efs

  • Period: 60
  • StDevs: 2

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

 

Download File:
RelativeVolume.efs
FreedomOfMovement.efs

RelativeVolume.efs, FreedomOfMovement.efs



EFS Code:

RelativeVolume.efs

/*********************************
Provided By:  
    Interactive Data Corporation (Copyright В© 2014) 
    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:        
    RelativeVolume by Melvin E. Dickover: 
    finds spikes of volume above numStDevs standard
    deviations of the average volume of the lookback period.

Formula Parameters:                     Default:
Period                                  60
StDevs                                  2 

Version:            1.00  14/05/2014

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("RelativeVolume");
    setPlotType(PLOTTYPE_HISTOGRAM);
  
    var x = 0;

    fpArray[x] = new FunctionParameter("fpPeriod", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("Period");
        setDefault(60);
        setLowerLimit(1);
    }

    fpArray[x] = new FunctionParameter("fpNumStDevs", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("StDevs");
        setDefault(2);
    }
}

var bInit = false;
var bVersion = null;

var x_Volume = null;
var x_av = null;
var x_sd = null;
var x_relVol = null;

function main(fpPeriod, fpNumStDevs) 
{
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;
    
    if (!bInit)
    {   
        x_Volume = volume();

        x_av = sma(fpPeriod, x_Volume);
        x_sd = efsInternal("Calc_Std", fpPeriod, x_Volume);
        x_relVol = efsInternal("Calc_Rel", x_Volume, x_av, x_sd);
     
        bInit = true;
    }

    var n_RelVol = x_relVol.getValue(0);

    if (n_RelVol == null)
        return;

    if (n_RelVol > fpNumStDevs)
        setBarFgColor(Color.blue)
    else
        setBarFgColor(Color.grey);
  
    return n_RelVol;
}

var xSMA = null;

function Calc_Std(nPeriod, xSourse)
{
    if (getBarState() == BARSTATE_ALLBARS)
    {
        xSMA = sma(nPeriod, xSourse);
    } 

    var nSMA = xSMA.getValue(0);

    if (nSMA == null)
        return;

    var nSum = 0;

    for (var i = 0; i < nPeriod; i++)
    {
       var nSource = xSourse.getValue(-i);
       
       if (nSource == null)
           return;

       var nVal = Math.pow((nSource - nSMA), 2);
       
       nSum += nVal; 
    }

    var nReturnValue = Math.sqrt(nSum / nPeriod);
          
    return nReturnValue;
}

function Calc_Rel(xSourse, xSourseAV, xSourseSD)
{
    var nSourse = xSourse.getValue(0);
    var nSourseAV = xSourseAV.getValue(0);
    var nSourseSD = xSourseSD.getValue(0);

    if(nSourse == null || nSourseAV == null || nSourseSD == null)
        return; 

    var nReturnValue = (nSourse - nSourseAV) / nSourseSD;          
          
    return nReturnValue;
}

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

FreedomOfMovement.efs

/*********************************
Provided By:  
    Interactive Data Corporation (Copyright В© 2014) 
    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:        
    FreedomOfMovement by Melvin E. Dickover: 
    computes how much effort to move the close up or down from previous bar.
    Effort is defined as the normalized relative volume.
    Effect is the normalized percent of (close - previous close).
    The resulting Freedom of Movement is the relative ratio of effort/effect.
    The larger the spike in FoM, the more the restriction of freedom of movement.
    Price movement is easy when FoM is small or negative,
    that is, only a small volume required to move price appreciably.

Formula Parameters:                     Default:
Period                                  60
StDevs                                  2 

Version:            1.00  14/05/2014

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("FreedomOfMovement");
    setPlotType(PLOTTYPE_HISTOGRAM);
  
    var x = 0;

    fpArray[x] = new FunctionParameter("fpPeriod", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("Period");
        setDefault(60);
        setLowerLimit(1);
    }

    fpArray[x] = new FunctionParameter("fpNumStDevs", FunctionParameter.NUMBER);
    with(fpArray[x++])
    {
        setName("StDevs");
        setDefault(2);
    }
}

var bInit = false;
var bVersion = null;

var x_Volume = null;

var x_aMove = null;
var x_theMin = null;
var x_theMax = null;
var x_theMove = null;

var x_av = null;
var x_sd = null;
var x_relVol = null;

var x_theMinV = null;
var x_theMaxV = null;
var x_theVol = null;

var x_vByM = null;
var x_avF = null;
var x_sdF = null;
var x_theFoM = null;

function main(fpPeriod, fpNumStDevs) 
{
    if (bVersion == null) bVersion = verify();
    if (bVersion == false) return;
    
    if (!bInit)
    {   
        x_aMove = efsInternal("Calc_aMove");
        x_theMin = llv(fpPeriod, x_aMove);
        x_theMax = hhv(fpPeriod, x_aMove);
        x_theMove = efsInternal("Calc_Effort_Effect", x_aMove, x_theMin, x_theMax);

        x_Volume = volume();
        x_av = sma(fpPeriod, x_Volume);
        x_sd = efsInternal("Calc_Std", fpPeriod, x_Volume);
        x_relVol = efsInternal("Calc_Rel", x_Volume, x_av, x_sd);

        x_theMinV = llv(fpPeriod, x_relVol);
        x_theMaxV = hhv(fpPeriod, x_relVol);
        x_theVol = efsInternal("Calc_Effort_Effect", x_relVol, x_theMinV, x_theMaxV);

        x_vByM = efsInternal("Calc_vByM", x_theMove, x_theVol);

        x_avF = sma(fpPeriod, x_vByM);
        x_sdF = efsInternal("Calc_Std",fpPeriod, x_vByM);
        x_theFoM = efsInternal("Calc_Rel", x_vByM, x_avF, x_sdF);
   
        bInit = true;
    }

    var n_theFoM = x_theFoM.getValue(0);
    
    if (n_theFoM == null)
        return;

    if (n_theFoM < fpNumStDevs)
        setBarFgColor(Color.grey)
    else
        setBarFgColor(Color.blue);
  
    return n_theFoM;
}

var xSMA = null;

function Calc_Std(nPeriod, xSourse)
{
    if (getBarState() == BARSTATE_ALLBARS)
    {
        xSMA = sma(nPeriod, xSourse);
    } 

    var nSMA = xSMA.getValue(0);

    if (nSMA == null)
        return;

    var nSum = 0;

    for (var i = 0; i < nPeriod; i++)
    {
       var nSource = xSourse.getValue(-i);
       
       if (nSource == null)
           return;

       var nVal = Math.pow((nSource - nSMA), 2);
       
       nSum += nVal; 
    }

    var nReturnValue = Math.sqrt(nSum / nPeriod);
          
    return nReturnValue;
}

function Calc_Rel(xSourse, xSourseAV, xSourseSD)
{
    var nSourse = xSourse.getValue(0);
    var nSourseAV = xSourseAV.getValue(0);
    var nSourseSD = xSourseSD.getValue(0);

    if(nSourse == null || nSourseAV == null || nSourseSD == null)
        return; 

    var nReturnValue = (nSourse - nSourseAV) / nSourseSD;          
          
    return nReturnValue;
}

var xClose = null;

function Calc_aMove()
{
    if (getBarState() == BARSTATE_ALLBARS)
    {
        xClose = close();
    } 

    var nClose = xClose.getValue(0);
    var nPrevClose = xClose.getValue(-1);

    if (nClose == null || nPrevClose == null)
        return;
    
    var nReturnValue = Math.abs((nClose - nPrevClose) / nPrevClose);

    return nReturnValue;
}

function Calc_Effort_Effect(xSourse, xSourceMin, xSourceMax)
{
    var nSourse = xSourse.getValue(0);
    var nSourseMin = xSourceMin.getValue(0);
    var nSourseMax = xSourceMax.getValue(0);

    if(nSourse == null || nSourseMin == null || nSourseMax == null)
        return; 

    var nReturnValue = 0;
    
    if (nSourseMax > nSourseMin) 
        nReturnValue = 1 + ((nSourse - nSourseMin) * (10 - 1)) / (nSourseMax - nSourseMin);          
          
    return nReturnValue;
}

function Calc_vByM(xSourceMove, xSourceVol)
{
    var nSourceMove = xSourceMove.getValue(0);
    var nSourceVol = xSourceVol.getValue(0);
   
    if(nSourceMove == null || nSourceVol == null)
        return;

    return nSourceVol / nSourceMove;
}

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