Announcement

Collapse
No announcement yet.

TICK in Cursor bar

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

  • TICK in Cursor bar

    Hello,

    I am displaying the TICK and TRIN values in the cursor window. It works fine for all time intervals except for 5 minutes. When I change to 5 minutes, it causes and error.

    What am I doing wrong?


    function preMain(){
    setPriceStudy(true);
    setCursorLabelName("TICK",0);
    setCursorLabelName("TRIN",1);
    }

    function main() {

    var nTickClose_1 = close( -1, sym("$TICK,5"));
    var nTrinClose_1 = close( -1,sym("$TRIN,5"));


    return new Array(nTickClose_1.toFixed(2),nTrinClose_1.toFixed (2));

  • #2
    edhecht
    Before using the .toFixed() method [or any other method that manipulates the properties of a value] you should always run a null check on the value to ensure that it is valid.
    Add the following line of code just before the return statement
    if(nTickClose_1==null || nTrinClose_1==null) return;
    and you should no longer get an error
    Alex

    Comment

    Working...
    X