Dynamo

ICE Data Services -

Dynamo.efs  

EFSLibrary - Discussion Board  

File Name: Dynamo.efs

Description:
Dynamo

Formula Parameters:

  • OscLen : 10
  • MALen : 20
  • LowBand : 23
  • HiBand : 77

Notes:
In July 1996 Futures magazine, E. Marshall Wall introduces the Dynamic Momentum Oscillator (Dynamo). Please refer to this article for interpretation. The Dynamo oscillator is a normalizing function which adjusts the values of a standard oscillator for trendiness by taking the difference between the value of the  oscillator and a moving average of the oscillator and then subtracting that value from the oscillator midpoint.

Download File:
Dynamo.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:        
    Dynamo  
    
Version:            1.0  04/15/2009

Formula Parameters:                     Default:
    OscLen                              10
    MALen                               20
    LowBand                             23
    HiBand                              77
    
Notes:
    In July 1996 Futures magazine, E. Marshall Wall introduces the 
    Dynamic Momentum Oscillator (Dynamo). Please refer to this article 
    for interpretation.
    The Dynamo oscillator is a normalizing function which adjusts the 
    values of a standard oscillator for trendiness by taking the difference 
    between the value of the oscillator and a moving average of the oscillator 
    and then subtracting that value from the oscillator midpoint.
**********************************/
var fpArray = new Array();
var bInit = false;

function preMain() {
    setStudyTitle("Dynamo");
    setCursorLabelName("Dynamo", 0);
    setDefaultBarFgColor(Color.brown, 0);
    setStudyMax(101);
    setStudyMin(-1);
    var x = 0;
    fpArray[x] = new FunctionParameter("OscLen", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setLowerLimit(1);
        setDefault(10);
    }
    fpArray[x] = new FunctionParameter("MALen", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setLowerLimit(1);
        setDefault(20);
    }
    fpArray[x] = new FunctionParameter("LowBand", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setLowerLimit(1);
        setDefault(23);
    }
    fpArray[x] = new FunctionParameter("HiBand", FunctionParameter.NUMBER);
    with(fpArray[x++]) {
        setLowerLimit(1);
        setDefault(77);
    }
}

var HighestSoFar = null;
var LowestSoFar = null;
var HighestSoFar_1 = null;
var LowestSoFar_1 = null;
var xOscAvg = null;
var xMAVal = null;

function main(OscLen, MALen, LowBand, HiBand){
var nBarState = getBarState();
var OscAvg = 0;
var MAVal = 0;
    if (nBarState == BARSTATE_ALLBARS) {
        if (OscLen == null) OscLen = 10;
        if (MALen == null) MALen = 20;
        if (LowBand == null) LowBand = 23;
        if (HiBand == null) HiBand = 77;
    }        

    if (bInit == false) {
        addBand(LowBand, PS_SOLID, 1, Color.blue, 1);
        addBand(HiBand, PS_SOLID, 1, Color.red, 2);
        xOscAvg = stochK(OscLen,OscLen,1);
        xMAVal = stochD(OscLen,OscLen,MALen);  
        bInit = true;
    }    
    
    OscAvg = xOscAvg.getValue(0);
    MAVal = xMAVal.getValue(0);
    
    if (OscAvg == null || MAVal == null) return;

    if (LowestSoFar == null || HighestSoFar == null) {
        LowestSoFar = OscAvg;
        HighestSoFar = OscAvg;
        LowestSoFar_1 = OscAvg;
        HighestSoFar_1 = OscAvg;
        return;
    }

    if (nBarState == BARSTATE_NEWBAR) {
        LowestSoFar_1 = LowestSoFar;
        HighestSoFar_1 = HighestSoFar;
    }

    if (OscAvg < LowestSoFar_1) 
        LowestSoFar = OscAvg;
    else 
        LowestSoFar = LowestSoFar_1;
    if (OscAvg > HighestSoFar_1) 
        HighestSoFar = OscAvg;
    else 
        HighestSoFar = HighestSoFar_1;
    var MidPnt = (LowestSoFar + HighestSoFar) / 2;
    var Res = MidPnt - (MAVal - OscAvg);
    return Res;
}