Announcement

Collapse
No announcement yet.

efs help

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

  • efs help

    I encountered some code that I am trying to understand. Below is part of the EFS for 123up (FORMULAS>HELPERS>123up.efs).

    I would greatly appreciate it if someone could explain the following lines to me, starting under the var...

    Thank you.



    function main(nBars) {
    var i = 0;
    var nStateTotal = 0;

    if(low(-nBars) == null) return;

    for(i = 0; i < nBars-1; i++) {
    if(low(-i) >= low(-i-1)) {
    nStateTotal = nStateTotal + 1;
    } else {
    break;
    }
    }

  • #2
    erikguz
    That section of code uses a for loop to increase the variable nStateTotal by 1 each time the condition low(0)>=low(-1) is true within the previous number of bars defined by the parameter nBars (in other words it counts how many instances of that condition exist in the defined number of bars)
    For a complete description of the for loop including examples on how to use it you may want to review this article of the Core JavaScript Guide which is in the EFS KnowledgeBase. The for loop is also explained in the JavaScript for EFS video series
    Alex


    Originally posted by erickguz
    I encountered some code that I am trying to understand. Below is part of the EFS for 123up (FORMULAS>HELPERS>123up.efs).

    I would greatly appreciate it if someone could explain the following lines to me, starting under the var...

    Thank you.



    function main(nBars) {
    var i = 0;
    var nStateTotal = 0;

    if(low(-nBars) == null) return;

    for(i = 0; i < nBars-1; i++) {
    if(low(-i) >= low(-i-1)) {
    nStateTotal = nStateTotal + 1;
    } else {
    break;
    }
    }

    Comment


    • #3
      I had been looking for some reference point, I simply didn't know the term I was looking for was "loop."

      Thanks.

      Comment


      • #4
        erikguz
        You are most welcome
        Alex


        Originally posted by erickguz
        I had been looking for some reference point, I simply didn't know the term I was looking for was "loop."

        Thanks.

        Comment

        Working...
        X