Announcement

Collapse
No announcement yet.

Center of Gravity oscilator.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Center of Gravity oscilator.

    Got it from S&C, many syntax errors. Looks like the ones on lines 60+ are giving me hard time especially since I'm cluless when it comes to programming anything. Any help could be great. Thanks.





    /************************************************** ******************************
    Description: This formula plots the Center of Gravity Oscillator
    Provided By: This formula was created in the eSignal Formula Editor
    Copyright 2002 eSignal, A division of Interactive Data Corporation
    ************************************************** *******************************/


    function preMain() {

    setStudyTitle("CG Oscillator");

    setCursorLabelName("CG-Osc", 0);

    setCursorLabelName("CG-Osc1", 1);

    setDefaultBarFgColor(Color.red, 0);

    setDefaultBarFgColor(Color.blue, 1);



    //setDefaultBarThickness(2, 0);

    //setDefaultBarThickness(2, 1);

    } >

    function main(nInputLength) {

    if(nInputLength == null)

    nInputLength = 10; >

    var vRef;

    var nCount;

    var dDenom = 0; >

    var dNum = 0; >

    var dCG = 0; >

    var vH, vL;

    var vPrice;

    vH = high(0, -nInputLength); >

    vL = low(0, -nInputLength); >

    if(vH == null || vL == null)

    return;

    for(nCount = 0; nCount < nInputLength; nCount++) {

    vPrice = (vH[nCount] + vL[nCount]) / 2 >

    dNum += (1 + nCount) * vPrice; >

    dDenom += vPrice; >

    }

    if(dDenom != 0) >

    dCG = -dNum / dDenom; >

    vRef = ref(-1); >

    if(vRef == null) { return new Array(dCG, null);

    } else {

    return new Array(dCG, vRef[0]);

    }

    } >

  • #2
    Never mind, I found a working one.

    Comment

    Working...
    X