Announcement

Collapse
No announcement yet.

ConnorHistVolatility.efs

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • ConnorHistVolatility.efs

    File Name: ConnorHistVolatility.efs

    Description:
    Larry Connor’s Historical Volatility

    Formula Parameters:
    nLength1: Default is 6
    nLength2: Default is 100

    Notes:

    Download File:
    ConnorHistVolatility.efs

    Image:



    EFS Code:
    PHP Code:
    /*********************************
    Provided By : eSignal. (c) Copyright 2003
    *********************************/

    function preMain() {
        
    setStudyTitle("Historical Volatility");
        
    setCursorLabelName("HV "0);
        
    setCursorLabelName(" "1);
        
    setDefaultBarFgColor(Color.blue0);
        
    setDefaultBarFgColor(Color.black1);
    }

    function 
    STDV(length) {
        var 
    sumX 0;
        var 
    sumX2 0;
        for (
    0length; ++i) {
            
    sumX += aLog[i];
            
    sumX2 += (aLog[i] * aLog[i])
        }
        var 
    meanX = (sumX/length);
        var 
    stdev Math.sqrt((sumX2/length) - (meanX*meanX));

        return 
    stdev;
    }

    var 
    aLog null;

    function 
    main(nLength1nLength2) {
        if (
    nLength1 == null || nLength1 3)
            
    nLength1 6;
        if (
    nLength2 == null)
            
    nLength2 100;

        var 
    close();
        if (
    == null)
            return;
        
        if (
    aLog == null && close(-nLength2-1) != null) {
            
    aLog = new Array(nLength2);
            for (
    0nLength2; ++i) {
                
    aLog[i] = Math.log(close(-i)/close(-i-1));
            }
        }

        if (
    aLog[nLength2-1] == null)
            return;

        if (
    getBarState() == BARSTATE_NEWBAR) {
            
    aLog.pop()
            
    aLog.unshift(Math.log(c/close(-1)));
        } else {
            
    aLog[0] = Math.log(c/close(-1));
        }
        
        var 
    stdv1 STDV(nLength1);
        var 
    stdv2 STDV(nLength2);
        
        var 
    HV = (stdv1 Math.sqrt(256) * 100) / (stdv2 Math.sqrt(256) * 100);
        
        if (
    HV .5) {
            
    //setPriceBarColor(Color.cyan);
            
    setBarBgColor(Color.red);
        } else {
            
    setBarBgColor(Color.white);
        }
        
        return new Array(
    HV.5);

    Jason K.
    Project Manager
    eSignal - an Interactive Data company

    EFS KnowledgeBase
    JavaScript for EFS Video Series
    EFS Beginner Tutorial Series
    EFS Glossary
    Custom EFS Development Policy

    New User Orientation
Working...
X