Announcement

Collapse
No announcement yet.

Does a "ValueWhen" type of function exist?

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

  • Does a "ValueWhen" type of function exist?

    Hallo Forum


    I've created my own "Range" indicator inspired by the "Bollinger bands", allowing me to always keep track of where the Close is relative to its 52 week High/Low. The formula looks like this.


    function preMain() {
    setDefaultBarFgColor(Color.white, 0);
    setStudyTitle("Range");
    setCursorLabelName("Range");
    addBand( 50, PS_SOLID, 3, Color.black, 0);
    }

    function main ()

    {return (close()-llv(252,low()))/(hhv(252,high())-llv(252,low()))*100}


    Suposse I'm dealing with a stock in an extensive uptrend and it turnes out that the last time it produced what I call a genuine "All Time Low" (AroonDown (set to 252) = 100) was way more than 252 days ago; then I would have to not only replace the LLV/HHV functions with the AroonUp & AroonDown indicators, I would also have to reference that particular "ATL" which was produced the last time AroonDown (set to 252) went to a 100. In Metastock you use the "ValueWhen" function to do it:

    (C-ValueWhen(1,AroonDown(252) = 100,L))/(ValueWhen(1,AroonUp(252) =100,H)-ValueWhen(1,AroonDown(252) = 100,L))

    What I would like to know is whether there exsists a similar functionallity in Java script?



    Kind reagrds

    Gotan4711
    Last edited by gotan4711; 08-06-2013, 12:14 PM.

  • #2
    Mads
    FWIW the equation returned by your “Range” indicator is none other than a raw Stochastic %K of 252 periods.
    As to the ValueWhen function there isn’t an equivalent in efs so you will need to write your own
    Alex


    Originally posted by gotan4711 View Post
    Hallo Forum


    I've created my own "Range" indicator inspired by the "Bollinger bands", allowing me to always keep track of where the Close is relative to its 52 week High/Low. The formula looks like this.


    function preMain() {
    setDefaultBarFgColor(Color.white, 0);
    setStudyTitle("Range");
    setCursorLabelName("Range");
    addBand( 50, PS_SOLID, 3, Color.black, 0);
    }

    function main ()

    {return (close()-llv(252,low()))/(hhv(252,high())-llv(252,low()))*100}


    Suposse I'm dealing with a stock in an extensive uptrend and it turnes out that the last time it produced what I call a genuine "All Time Low" (AroonDown (set to 252) = 100) was way more than 252 days ago; then I would have to not only replace the LLV/HHV functions with the AroonUp & AroonDown indicators, I would also have to reference that particular "ATL" which was produced the last time AroonDown (set to 252) went to a 100. In Metastock you use the "ValueWhen" function to do it:

    (C-ValueWhen(1,AroonDown(252) = 100,L))/(ValueWhen(1,AroonUp(252) =100,H)-ValueWhen(1,AroonDown(252) = 100,L))

    What I would like to know is whether there exsists a similar functionallity in Java script?



    Kind reagrds

    Gotan4711

    Comment

    Working...
    X