Announcement

Collapse
No announcement yet.

OHLC/4 in custom formulas

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

  • OHLC/4 in custom formulas

    I am trying to determine how to find the value of OHLC/4 of a give bar . I currently use the following and I expect it is not very effecient .

    var OValues = new Array(nLength-1);
    var HValues = new Array(nLength-1);
    var LValues = new Array(nLength-1);
    var CValues = new Array(nLength-1);
    var yValues = new Array(nLength-1);

    OValues = getValue("Open", 0, -Length);
    HValues = getValue("High", 0, -Length);
    LValues = getValue("Low", 0, -Length);
    CValues = getValue("Close", 0, -Length);

    if (OValues == null || HValues == null || LValues == null || CValues == null ) {return;}

    for (i = 0; i < nLength; ++i)
    {yValues[i] = ((OValues[i] + HValues[i] + LValues[i] + CValues[i])/4);}

    I would like to replace with this :

    yValues = getValue("(O+H+L+C)/4", 0, -Length);

    but can't seem to get it to work . Is this possible with the correct syntax of OHLC/4

    Thanks

  • #2
    Re: Reply to post 'OHLC/4 in custom formulas'

    Bill, one quick comment - to save some cpu cycles.

    You don't need to do this:
    PHP Code:
    > var OValues = new Array(nLength-1);
    > var 
    HValues = new Array(nLength-1);
    > var 
    LValues = new Array(nLength-1);
    > var 
    CValues = new Array(nLength-1);
    > var 
    yValues = new Array(nLength-1); 
    It's automatically done when you call getValue.

    m.

    --- [email protected] wrote:
    > Hello mattgundersen,
    >
    > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    >
    Matt Gundersen

    Comment

    Working...
    X