Announcement

Collapse
No announcement yet.

Adding Band to Builtin PercentR Study

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

  • Adding Band to Builtin PercentR Study

    I need help trying to add bands at the -20 and the -80 to the "builtinPercentR" study. I did a search in the forum for "add band" and didn't find anything relevant to what i'm trying to do.

    I added this thinking it would work -

    addBand(-20, PS_SOLID, 2, Color.yellow, "a");
    addBand(-80, PS_SOLID, 2, Color.black, "b");

    It didn't

    here's how it looks in the study -

    /************************************************** *******
    Alexis C. Montenegro © July 2003
    Use and/or modify this code freely. If you redistribute it
    please include this and/or any other comment blocks and a
    description of any changes you make.
    ************************************************** ********/

    var vPercentR = null;

    function preMain() {
    setStudyTitle("PercentR");
    setCursorLabelName("%R", 0);
    setDefaultBarFgColor(Color.blue, 0);
    setDefaultBarThickness(1,0);

    addBand(-20, PS_SOLID, 2, Color.yellow, "a");
    addBand(-80, PS_SOLID, 2, Color.black, "b");

    var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
    fp1.setLowerLimit(1);
    fp1.setDefault(10); //Edit this value to set a new default

    }

    function main(Length) {

    if (vPercentR == null) vPercentR = new PercentRStudy(Length);

    /************************************************** *********
    Insert your code following this text block
    Use vPercentR.getValue(PercentRStudy.PERCENTR) for your code
    ************************************************** **********/


    return vPercentR.getValue(PercentRStudy.PERCENTR);
    }

    Any help is appreciated.

  • #2
    Re: Adding Band to Builtin PercentR Study

    jphillips9
    FWIW the formula you posted is working fine and the bands are displaying (see enclosed screenshot)
    Alex




    Originally posted by jphillips9
    I need help trying to add bands at the -20 and the -80 to the "builtinPercentR" study. I did a search in the forum for "add band" and didn't find anything relevant to what i'm trying to do.

    I added this thinking it would work -

    addBand(-20, PS_SOLID, 2, Color.yellow, "a");
    addBand(-80, PS_SOLID, 2, Color.black, "b");

    It didn't

    here's how it looks in the study -

    /************************************************** *******
    Alexis C. Montenegro © July 2003
    Use and/or modify this code freely. If you redistribute it
    please include this and/or any other comment blocks and a
    description of any changes you make.
    ************************************************** ********/

    var vPercentR = null;

    function preMain() {
    setStudyTitle("PercentR");
    setCursorLabelName("%R", 0);
    setDefaultBarFgColor(Color.blue, 0);
    setDefaultBarThickness(1,0);

    addBand(-20, PS_SOLID, 2, Color.yellow, "a");
    addBand(-80, PS_SOLID, 2, Color.black, "b");

    var fp1 = new FunctionParameter("Length", FunctionParameter.NUMBER);
    fp1.setLowerLimit(1);
    fp1.setDefault(10); //Edit this value to set a new default

    }

    function main(Length) {

    if (vPercentR == null) vPercentR = new PercentRStudy(Length);

    /************************************************** *********
    Insert your code following this text block
    Use vPercentR.getValue(PercentRStudy.PERCENTR) for your code
    ************************************************** **********/


    return vPercentR.getValue(PercentRStudy.PERCENTR);
    }

    Any help is appreciated.

    Comment


    • #3
      Thanks Alex. Esignal got confused I think I deleted it and then added it back and it didn't work. i then deleted it restarted Esignal and then applied it again and it worked.

      One more thing. Besides adding a moving average from the moving average's "setting source", how do i code a moving average into the percentR study?

      Thanks,
      Jeremiah

      Comment


      • #4
        Jeremiah
        You can find one already coded in this folder of my FileShare group
        Note that the efs I am suggesting calculates the PercentR and its moving average using the efs2 functions rather than the legacy [ie efs1] function used in the script you posted.
        It is possible to calculate the moving average of the PercentR also with the legacy function. If for whatever reason you would prefer that or would simply see how it is done you can find the efs1 equivalent study in this folder which is also in my FileShare group
        Alex


        Originally posted by jphillips9
        Thanks Alex. Esignal got confused I think I deleted it and then added it back and it didn't work. i then deleted it restarted Esignal and then applied it again and it worked.

        One more thing. Besides adding a moving average from the moving average's "setting source", how do i code a moving average into the percentR study?

        Thanks,
        Jeremiah

        Comment


        • #5
          Awesome!

          Thanks for this and all you do on the forums.

          Comment


          • #6
            Jeremiah
            You are most welcome
            Alex


            Originally posted by jphillips9
            Awesome!

            Thanks for this and all you do on the forums.

            Comment

            Working...
            X