Announcement

Collapse
No announcement yet.

Script Error in "Ease og movement"

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

  • Script Error in "Ease og movement"

    Hallo Forum

    If you take a look at my screen shot, you will notice that for some strange reason the "Ease of movement" study shows no data after the fourth of June. I have no idea how to correct this error in the script. Hope somebody can assist me in locating the incorrect line.


    Kind regards

    Gotan4711
    Attached Files
    Last edited by gotan4711; 07-04-2013, 06:58 AM.

  • #2
    Mads
    Any time you perform a division [such as for example when calculating nBoxRatio] you should first run a check for 0 or null on the divisor and if this is true you interrupt the execution of the script eg
    if(myDivisor==0 || isNull(myDivisor)) return;
    myDivision = myDividend / myDivisor;

    else the equation will return Infinity if the divisor is 0 or NaN if both the dividend and divisor are 0 as is the case on June 5th (see image enclosed below) where the Volume is 0 and the High and Low are the same price (hence returning 0 when subtracted one from the other)
    Alex




    Originally posted by gotan4711 View Post
    Hallo Forum

    If you take a look at my screen shot, you will notice that for some strange reason the "Ease of movement" study shows no data after the fourth of June. I have no idea how to correct this error in the script. Hope somebody can assist me in locating the incorrect line.


    Kind regards

    Gotan4711

    Comment


    • #3
      Originally posted by Alexis C. Montenegro View Post
      Mads
      Any time you perform a division [such as for example when calculating nBoxRatio] you should first run a check for 0 or null on the divisor and if this is true you interrupt the execution of the script eg
      if(myDivisor==0 || isNull(myDivisor)) return;
      myDivision = myDividend / myDivisor;

      else the equation will return Infinity if the divisor is 0 or NaN if both the dividend and divisor are 0 as is the case on June 5th (see image enclosed below) where the Volume is 0 and the High and Low are the same price (hence returning 0 when subtracted one from the other)
      Alex

      Alex

      Thanks a lot, it really worked! First I tried to write the line in the script, but for some reason I couldn't print the two vertical lines and there fore I was forced to use the copy paste function instead. So now the latter part of the script looks like this:

      nMidMove = ((high()+low())/2) - ((high(-1)+low(-1))/2);

      if(volume==0 || isNull(volume)) return;

      nBoxRatio = (volume()/10000) / (high()-low());

      nEMV = nMidMove / nBoxRatio;


      May I ask what the two vertical lines means and why it isn't possible to write them in the script?


      Mads

      Comment


      • #4
        Mads
        Actually you are not running a check for 0 or null on volume. That line of code should have been
        if(volume()==0 || isNull(volume())) return;
        Anyhow you are running a check on the dividend and while this may work in this instance you really should be running it on the divisor as good practice. While in JavaScript dividing by 0 returns Infinity [assuming the dividend is not 0] in many other environments it returns a “Divide by 0” error.
        With regards to the meaning of the two vertical lines [aka “pipes”] see this article in the EFS KnowledgeBase on JavaScript operators.
        Not sure what you mean that it is not possible to write them in the script. I use them all the time Shift+\ or Alt+124 (on numeric keypad).
        Alex


        Originally posted by gotan4711 View Post
        Alex

        Thanks a lot, it really worked! First I tried to write the line in the script, but for some reason I couldn't print the two vertical lines and there fore I was forced to use the copy paste function instead. So now the latter part of the script looks like this:

        nMidMove = ((high()+low())/2) - ((high(-1)+low(-1))/2);

        if(volume==0 || isNull(volume)) return;

        nBoxRatio = (volume()/10000) / (high()-low());

        nEMV = nMidMove / nBoxRatio;


        May I ask what the two vertical lines means and why it isn't possible to write them in the script?


        Mads

        Comment

        Working...
        X