Announcement

Collapse
No announcement yet.

KeltnerAtrEmaAdj.efs

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

  • KeltnerAtrEmaAdj.efs

    File Name: KeltnerAtrEmaAdj.efs

    Description:
    Keltner study with a 20 period exponential moving average of the basis line and bands based on 2.5 * Average True Range.

    Formula Parameters:
    nInputLength: Default is 20 (number of periods for basis line)
    nRangeFactor: Default is 2.5 (multiplier for the bands)

    Notes:


    Download File:
    KeltnerAtrEmaAdj.efs




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

    function preMain() {
        
    setPriceStudy(true);
        
        
    setStudyTitle("Keltner (ATR Bands) ");

        
    setCursorLabelName("K-Upper"0);
        
    setCursorLabelName("K-Basis"1);
        
    setCursorLabelName("K-Lower"2);

        
    setDefaultBarFgColor(Color.blue0); // upper
        
    setDefaultBarFgColor(Color.red1); // basis
        
    setDefaultBarFgColor(Color.blue2); // lower
    }

    function 
    ATR(nInputLength) {
        var 
    dSum 0;
        var 
    dH high(0, -nInputLength);
        var 
    dL low(0, -nInputLength);
        var 
    dC close(-1, -nInputLength);
        if (
    dH == null || dL == null || dC == null) {
            return;
        }
        for (
    0nInputLength; ++i) {
            var 
    vTrueHigh Math.max(dH[i], dC[i]);
            var 
    vTrueLow Math.min(dL[i], dC[i]);
            var 
    vTrueRange = (vTrueHigh vTrueLow);
            
    dSum += vTrueRange;
        }
        
    dSum /= nInputLength;
        return 
    dSum;
    }

    var 
    BarCntr 0;
    function 
    main(nInputLengthnRangeFactor) {
        if(
    nInputLength == null)
            
    nInputLength 20;
        if(
    nInputLength <= 0)
            
    nInputLength 20;

        if(
    nRangeFactor == null)
            
    nRangeFactor 2.5;
        if(
    nRangeFactor <= 0)
            
    nRangeFactor 2.5;

        if (
    getBarState() == BARSTATE_NEWBAR)
            
    BarCntr += 1;
        
        if (
    BarCntr nInputLength) {
            return;
        } else {
            var 
    dKeltnerBasiscall("/Library/KeltnerEMA.efs"nInputLength);
            var 
    dATR ATR(nInputLength);
            return new Array(
    dKeltnerBasis + (nRangeFactor dATR), dKeltnerBasisdKeltnerBasis - (nRangeFactor dATR));
        }

    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