Announcement

Collapse
No announcement yet.

Can't display Highest High

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

  • Can't display Highest High

    I am having difficulty displaying the highest high for the year. I believe I am not using the highest() function properly.

    How can I get a line on the chart to display the highest high?

    Thanks for any help.

    Perry

    Here is the failing code:

    var seriesHH=0;

    function preMain() {

    setStudyTitle("MMD252dH&L");
    setCursorLabelName("MMD252dH&L",0);

    setDefaultBarFgColor(Color.black,0);

    setPriceStudy(true);
    }

    function main() {

    seriesHH=highest(252,high());
    return(seriesHH());
    }

  • #2
    Try This..

    PHP Code:

    var seriesHH=0;

    function 
    preMain() {

    setStudyTitle("MMD252dH&L");
    setCursorLabelName("MMD252dH&L",0);

    setDefaultBarFgColor(Color.black,0);

    setPriceStudy(true);
    }

    function 
    main() {

    seriesHH=highest(252,high()); 
    return 
    seriesHH;

    You don't want to return "seriesHH()" because that FUNCTION does not exist. You want to return the VARIABLE NAME that contains the Highest High value.
    Brad Matheny
    eSignal Solution Provider since 2000

    Comment


    • #3
      Brad,

      Thank you for your reply.

      I copied and pasted your code into my EFS study, checked, saved and reloaded, but I still don't see any lines on my chart.

      Does it work for you?

      Perry

      Comment


      • #4
        And, when I insert

        debugPrintln(seriesHH);

        it just returns

        [object Series]

        Why does it not return a number?

        perry

        Comment


        • #5
          Object Series values are not simple numbers. They are (normally) an array (or series of numbers).

          Try using ...

          debugPrintln(seriesHH.getValue(0));

          and see if you get a valid number.

          B
          Brad Matheny
          eSignal Solution Provider since 2000

          Comment


          • #6
            Thank you for your continuing help.

            Here are the two line of code in Main

            seriesHH=highest(252,high());
            debugPrintln(seriesHH.getValue(0));

            now the Formula Output window returns

            null

            on every line

            so there is no value in seriesHH?

            perry

            Comment


            • #7
              OK, I fixed it

              I didn't have 252 days of data on the chart, so it couldn't display the highest high in 252 days.

              I put 1000 bars on the chart and the line shows fine.

              Thank you for all the help.

              perry

              Comment


              • #8
                looks like you might have run into a limit with the number of bars you are trying to calculate with this function. If I change the value to 2 or 5, it works fine. Running it with your default value appears to result in a null return.

                You might have to try to write your own lookup function to handle this.

                PHP Code:
                var vHH=0;

                function 
                preMain() {

                setStudyTitle("MMD252dH&L");
                setCursorLabelName("MMD252dH&L",0);

                setDefaultBarFgColor(Color.black,0);

                setPriceStudy(true);
                }

                function 
                main() {

                vHH highest(52,high()); 
                debugPrintln(vHH.getValue(0));

                return 
                vHH.getValue(0);

                Brad Matheny
                eSignal Solution Provider since 2000

                Comment

                Working...
                X