Announcement

Collapse
No announcement yet.

Possible to modify?

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

  • Possible to modify?

    I have failed in my 82nd attempt to complete the following and seek some assistance.

    Below is the 123up.efs study.

    Is it possible to modify this formula to output "the sum of times L>L(-1)" during a 10-day period, and plot it as a simple line indicator? (yup, that's it...)

    Thanks for any help.


    function preMain() {
    setStudyTitle("123Up");
    setCursorLabelName("123Up");
    setPriceStudy(false)


    var fp1 = new FunctionParameter("nBars", FunctionParameter.NUMBER);
    fp1.setName("Number of Bars");
    fp1.setLowerLimit(1);
    fp1.setDefault(10);
    }

    /*
    * This functions shows when there are 3 or more up bars with higher lows
    * It is a pure color study.
    */

    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;
    }
    }

    if(nStateTotal == 0) {
    return ????
    }

    return;
    }

  • #2
    Re: Possible to modify?

    erikguz
    The first thing you need to do is modify the condition
    if(low(-i) >= low(-i-1)) {
    to the following
    if(low(-i) > low(-i-1)) {
    The condition will now evaluate only those bars in which the Low is greater than the prior Low instead of greater than OR equal to the prior Low
    Then delete or comment out the following section of code which is not required
    if(nStateTotal == 0) {
    return ????
    }

    and add nStateTotal to the return statement ie
    return nStateTotal;
    Once you make these changes the formula will plot the number of instances the condition occurred within the defined number of bars
    Alex


    Originally posted by erickguz
    I have failed in my 82nd attempt to complete the following and seek some assistance.

    Below is the 123up.efs study.

    Is it possible to modify this formula to output "the sum of times L>L(-1)" during a 10-day period, and plot it as a simple line indicator? (yup, that's it...)

    Thanks for any help.


    function preMain() {
    setStudyTitle("123Up");
    setCursorLabelName("123Up");
    setPriceStudy(false)


    var fp1 = new FunctionParameter("nBars", FunctionParameter.NUMBER);
    fp1.setName("Number of Bars");
    fp1.setLowerLimit(1);
    fp1.setDefault(10);
    }

    /*
    * This functions shows when there are 3 or more up bars with higher lows
    * It is a pure color study.
    */

    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;
    }
    }

    if(nStateTotal == 0) {
    return ????
    }

    return;
    }

    Comment

    Working...
    X