Announcement

Collapse
No announcement yet.

Getting Last Year High and Low

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

  • Getting Last Year High and Low

    In EFS2 you can get last month High and Low by using this

    vHigh = high(-1, inv("M"));
    vLow = low(-1, inv("M"));

    how can you get last Year High and Low?

    TIA

    Ketoma

  • #2
    Ketoma
    Declare two global variables (ie outside of function main) called for example lastYrHi and lastYrLo and set them to null.
    Then in main use the example shown below which will provide you with last year's high and low
    Alex

    PHP Code:
    if(year(0)!=year(-1)){
        
    lastYrHi upperDonchian(12,inv("m"),-1);
        
    lastYrLo lowerDonchian(12,inv("m"),-1);

    Comment


    • #3
      Thank you very much Alexis

      I will try it after the market today, I'm sure it will do the trick

      Thank you very much again

      Ketoma

      Comment


      • #4
        Alexis Works Great thank you

        how about if I want to get the high and low of two years ago 2004 do I do this

        if(year(-1)!=year(-2)){
        lastYrHi = upperDonchian(12,inv("m"),-2);
        lastYrLo = lowerDonchian(12,inv("m"),-2);
        }

        TIA

        Ketoma

        Comment


        • #5
          Ketoma
          You are most welcome
          To retrieve the values of two years back you maintain the same if() statement which identifies a change in year and then adjust the bar index of the study to -2 as shown in the following example
          Alex

          PHP Code:
          if(year(0)!=year(-1)){
              
          lastYrHi upperDonchian(12,inv("m"),-2);
              
          lastYrLo lowerDonchian(12,inv("m"),-2);

          Comment


          • #6
            Thank you very much Alexis

            What's am I doing wrong here, the last year High and low is correct but the year before is not


            TIA

            Ketoma
            Attached Files
            Last edited by ketoma21; 03-01-2006, 08:22 PM.

            Comment


            • #7
              NQ Monthly Chart
              Attached Files

              Comment


              • #8
                Ketoma
                Sorry that was my mistake. The bar index should be -13 and not -2 to plot the High/Low of 2 years ago
                Alex

                Comment


                • #9
                  Thank you very much Alexis

                  works great, you are wonderful

                  Ketoma

                  Comment


                  • #10
                    Ketoma
                    You are most welcome and thank you for the compliment
                    Alex

                    Comment

                    Working...
                    X