Announcement

Collapse
No announcement yet.

Referencing older data in watchlist seems to give problems

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

  • Referencing older data in watchlist seems to give problems

    Hello,

    Maybe anyone could help me with this one.

    I'm using a formula to calculate relatieve strenght, and display it in a watchlist.
    With nLenght up to 10 it's works fine, but any bigger value doesn't give any output (just green dots)

    Any help would be welcome
    Regards




    function rs( nLenght ) {

    var nRS = 0;
    var nRoC = 0;
    var nRoCRef = 0;

    var len = -(nLenght-1);


    nRoC = (close(0)-close(len))/close(len);
    nRoCRef = (close(0,sym("SPY"))-close(len,sym("SPY")))/close(len,sym("SPY"));

    nRS = (nRoC-nRoCRef)*100;

    return nRS;
    }

  • #2
    HHAG
    First of all as suggested in the guidelines for this forum you should post a complete script so that others who may want to help can try to do that without having to guess what else you may be doing
    That said I tested your function within a simple script and it is working just fine even when the length is greater than 10 (see enclosed screenshot)



    As an aside I am not sure why you would complicate your script rather than using the roc() function (and another small change) which would give you the same results as you can see in the image enclosed below
    Alex




    Originally posted by HHAG View Post
    Hello,

    Maybe anyone could help me with this one.

    I'm using a formula to calculate relatieve strenght, and display it in a watchlist.
    With nLenght up to 10 it's works fine, but any bigger value doesn't give any output (just green dots)

    Any help would be welcome
    Regards




    function rs( nLenght ) {

    var nRS = 0;
    var nRoC = 0;
    var nRoCRef = 0;

    var len = -(nLenght-1);


    nRoC = (close(0)-close(len))/close(len);
    nRoCRef = (close(0,sym("SPY"))-close(len,sym("SPY")))/close(len,sym("SPY"));

    nRS = (nRoC-nRoCRef)*100;

    return nRS;
    }

    Comment

    Working...
    X