Bill Williams Averages. 3Lines.

ICE Data Services -

BWAverages3lines.efs  
EFSLibrary - Discussion Board  

File Name: BWAverages3lines.efs

Description:
This Indicator plots Bill Williams Averages. 3Lines

Formula Parameters:

  • Long length: 13
  • Medium length: 8
  • Short length: 5
  • Displacement for long length: 8
  • Displacement for medium length: 5
  • Displacement for short length: 3

Notes:
This indicator calculates 3 Moving Averages for default values of 13, 8 and 5 days, with displacement 8, 5 and 3 days: Median Price (High+Low/2).

The most popular method of interpreting a moving average is to compare the relationship between a moving average of the security's price with the security's price itself (or between several moving averages).

Download File:
BWAverages3lines.efs


EFS Code:

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

Provided By:  

    eSignal (Copyright c eSignal), a division of Interactive Data 
    Corporation. 2008. 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:        

    This Indicator plots Bill Williams Averages. 3Lines

Version:            1.0  09/25/2008

Notes:

    This indicator calculates 3 Moving Averages for default values of
    13, 8 and 5 days, with displacement 8, 5 and 3 days: Median Price (High+Low/2).

    The most popular method of interpreting a moving average is to compare 
    the relationship between a moving average of the security's price with 
    the security's price itself (or between several moving averages).


Formula Parameters:                     Default:

    Long length                              13
    Medium length                             8
    Short length                              5
    Displacement for long length              8
    Displacement for medium length            5
    Displacement for short length             3

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

var bInit = false;
var fpArray = new Array();

function preMain() {

    setPriceStudy(true);
    setStudyTitle("Average Bill Williams 3 Lines");

    setCursorLabelName("BLblue", 0);
    setCursorLabelName("BLRed", 1);
    setCursorLabelName("BLGreen", 2);

    setDefaultBarFgColor(Color.blue, 0);
	setDefaultBarFgColor(Color.red, 1); 
	setDefaultBarFgColor(Color.green, 2);
	
	var x = 0;
	
	fpArray[x] = new FunctionParameter("LLength", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setName("Long length");
        setLowerLimit(1);
        setDefault(13);
    }
    
    fpArray[x] = new FunctionParameter("MLength", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setName("Medium length");
        setLowerLimit(1);
        setDefault(8);
    }

    fpArray[x] = new FunctionParameter("SLength", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setName("Short length");
        setLowerLimit(1);
        setDefault(5);
    }
    
    fpArray[x] = new FunctionParameter("LOffset", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setName("Long offset");
        setLowerLimit(1);
        setDefault(8);
    }
    
    fpArray[x] = new FunctionParameter("MOffset", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setName("Medium offset");
        setLowerLimit(1);
        setDefault(5);
    }
    
    fpArray[x] = new FunctionParameter("SOffset", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setName("Short offset");
        setLowerLimit(1);
        setDefault(3);
    }

}

var xhl2 = null;
var xLSma = null;
var xMSma = null;
var xSSma = null;


function main(LLength, MLength, SLength, LOffset, MOffset, SOffset) {

    if (LLength == null) LLength = 13;
    if (MLength == null) MLength = 8;
    if (SLength == null) SLength = 5;
    if (LOffset == null) LOffset = 8;
    if (MOffset == null) MOffset = 5;
    if (SOffset == null) SOffset = 3;

    if ( bInit == false ) { 
        xhl2 = hl2();
        xLSma = offsetSeries(sma(LLength, xhl2), LOffset);
        xMSma = offsetSeries(sma(MLength, xhl2), MOffset);
        xSSma = offsetSeries(sma(SLength, xhl2), SOffset);
        bInit = true; 
    } 

    var nLSma = 0;
    var nMSma = 0;
    var nSSma = 0;

    nLSma = xLSma.getValue(0);
    nMSma = xMSma.getValue(0);
    nSSma = xSSma.getValue(0);

    return new Array(nLSma, nMSma, nSSma);
}