Bill Williams. Awesome Oscillator (AC)

ICE Data Services -

ABillW_AC.efs  
EFSLibrary - Discussion Board  

File Name: ABillW_AC.efs

Description:
Bill Williams. Awesome Oscillator (AC)

Formula Parameters:

  • nLengthSlow : 34
  • nLengthFast : 5

Notes:

This indicator plots the oscillator as a histogram where blue denotes periods suited for buying and red . for selling. If the current value of AO (Awesome Oscillator) is above previous, the period is considered
suited for buying and the period is marked blue. If the AO value is not above previous, the period is considered suited for selling and the indicator marks it as red.

Download File:
ABillW_AC.efs


EFS Code:

/*********************************
Provided By:  
    eSignal (Copyright c eSignal), a division of Interactive Data 
    Corporation. 2009. 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:        
    Bill Williams. Awesome Oscillator (AC)

Version:            1.0  03/27/2009

Formula Parameters:                     Default:
    nLengthSlow                         34
    nLengthFast                         5

Notes:
    This indicator plots the oscillator as a histogram where blue denotes 
    periods suited for buying and red . for selling. If the current value 
    of AO (Awesome Oscillator) is above previous, the period is considered 
    suited for buying and the period is marked blue. If the AO value is not 
    above previous, the period is considered suited for selling and the 
    indicator marks it as red.
**********************************/

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

function preMain() {
    setStudyTitle("Average Bill Williams AC");
    setCursorLabelName("ABillW AC", 0);
    setDefaultBarThickness(2,0);
    setPlotType(PLOTTYPE_HISTOGRAM);
    var x=0;
    fpArray[x] = new FunctionParameter("nLengthSlow", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(1);		
        setDefault(34);
    }
    fpArray[x] = new FunctionParameter("nLengthFast", FunctionParameter.NUMBER);
	with(fpArray[x++]){
        setLowerLimit(1);		
        setDefault(5);
    }   
}

var xCalc_hl2 = null;
var xAC = null;

function main(nLengthFast, nLengthSlow) {
var nBarState = getBarState();
var nAC = 0;
var nAC1 = 0;

    if (nBarState == BARSTATE_ALLBARS) {
        if (nLengthSlow == null) nLengthSlow = 34;
        if (nLengthFast == null) nLengthFast = 5;
    }

    if (bInit == false) {
        xCalc_hl2  = efsInternal("CalcSMA1_SMA2", nLengthFast, nLengthSlow);
        xAC = efsInternal("Calc_AC", nLengthFast, xCalc_hl2, sma(nLengthFast, xCalc_hl2))
        bInit = true;
    }

    nAC = xAC.getValue(0);
    nAC1 = xAC.getValue(-1);
    if (nAC1 == null) return;
    if (nAC > nAC1) setBarFgColor(Color.blue);
        else setBarFgColor(Color.red);
    return nAC;
}

var bSecondInit = false;
var xSMA1_hl2 = null;
var xSMA2_hl2 = null;

function CalcSMA1_SMA2(nLengthFast, nLengthSlow) {
var nRes = 0;
var SMA1 = 0;
var SMA2 = 0;
    if (bSecondInit == false) {
        xSMA1_hl2 = sma(nLengthFast, hl2());
        xSMA2_hl2 = sma(nLengthSlow, hl2());
        bSecondInit = true;
    }
    SMA1 = xSMA1_hl2.getValue(0);
    SMA2 = xSMA2_hl2.getValue(0);
    if (SMA1 == null || SMA2 == null) return;
    nRes = SMA1 - SMA2;
    return nRes;
}

function Calc_AC(nLengthFast, xCalc_hl2, xSMA_hl2) {
var nRes = 0;
    if (xSMA_hl2.getValue(0) == null) return;
    nRes = xCalc_hl2.getValue(0) - xSMA_hl2.getValue(0);
    return nRes;
}