Announcement

Collapse
No announcement yet.

Getting Any Bar Index or number back

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Getting Any Bar Index or number back

    Hello

    How do you get the index number for a bar?

    Example:

    let say the high and low of the day

    the bar is -12 bars back or -5 etc....


    Thank you

    Ketoma
    Attached Files

  • #2
    ketoma21
    There are several ways you can do that.
    One method is to loop back the required number of bars to determine when an event has occurred. See this post for an example.
    Another is to check for an event as the formula loads all the bars from oldest to newest and record the bar count at that time the event occurrs using for example the getCurrentBarCount() function. Once you have that you can easily determine the bar index by subtracting the current bar count from the one you stored when the event occurred
    Alex

    Comment


    • #3
      Thank you Very much Alexis

      here is what I'm trying to do maybe you can guide me on which method is best

      Using Donchian Channels (20) I'm trying to find the last High and the last Low bar Index number


      Thank you very much

      Ketoma
      Attached Files

      Comment


      • #4
        Ketoma
        The example I indicated in my prior reply should do what you want with regards to the highest High. You will need to create a similar function/logic to determine the bar index of the lowest Low
        Alex

        Comment


        • #5
          Thank you very much Alexis

          To be honest, The market is sooooo slow today and I wanted to get this question out before the weekend so I can work on it. I looked at the Example very quickly, I'm going to look at the example after the market in detail.

          Thank you again

          Ketoma
          Last edited by ketoma21; 03-31-2006, 09:30 AM.

          Comment


          • #6
            Ketoma
            You are most welcome.
            As an alternative you can do the following. First create a global variable called for example BarIndexHHV and set it intially to 0. Then in function main you check for the High to be equal to the Upper Donchian and when that occurrs you assign the current bar count to the variable BarIndexHHV as follows
            PHP Code:
            if(high(0)==upperDonchian(20,0)){
                    
            BarIndexHHV getCurrentBarCount();

            At this point to determine the bar index of the last highest High value you would just calculate the difference between the current bar count and the variable BarIndexHHV
            PHP Code:
            var myVar getCurrentBarCount()-BarIndexHHV); 
            Repeat the process for the Low using the Lower Donchian
            Alex

            Comment


            • #7
              Thank you very much Alexis, this is what I was looking for

              Comment

              Working...
              X