It's amazing what a good night's sleep does for a little perspective.
Of course these functions only look back from the right edge of the chart - and 
do not produce full arrays.  Thus, they are of very little use.

That will teach me to try to be creative at 1 in the morning

 Best Regards
Rick Osborn




________________________________
From: Rick Osborn <ri...@rogers.com>
To: amibroker@yahoogroups.com
Sent: Sat, August 7, 2010 1:06:46 AM
Subject: Re: [amibroker] Multiple Higher Highs in Amibroker?

  
Interesting.  I've often wondered how to do that.
I have created a function that can be called based on this code.  I have 
quickly 
checked the results and think it works as intended.  


It is 1 based - not zero based.  To calculate the 4th Highest Close - pass C to 
array etc.
 
functionNextHiRank ( array,  Lookback, element ) 
// to get 4th Highest High in last 10  periods call NextHiRank (H,10,4)
{ 
    element = Min(Lookback, element)-1; 
    bi = BarIndex(); 
    a = LastValue( bi ); 
    b = a - Lookback; 
    z = IIf( bi >= b, array, Null); 

    for( i = b;i <= a;i++ ) 
    { 

        for( j = i + 1;j <= a;j++ ) 
        { 

            if( z[i] < z[j] ) 
            { 
                temp = z[i]; 
                z[i] = z[j]; 
                z[j] = temp; 
            } 
        } 
    } 

    returnz[b + element]; 
} 

 

Based on the same logic - here is the NextLoRank function.

functionNextLoRank ( array,  Lookback, element ) 
{ 
    element = Min(Lookback, element)-1; 
    bi = BarIndex(); 
    a = LastValue( bi ); 
    b = a - Lookback; 
    z = IIf( bi >= b, array, Null); 

    for( i = b;i <= a;i++ ) 
    { 

        for( j = i + 1;j <= a;j++ ) 
        { 

            if( z[i] > z[j] ) 
            { 
                temp = z[i]; 
                z[i] = z[j]; 
                z[j] = temp; 
            } 
        } 
    } 

    returnz[b + element]; 
} 

Thanks to Inquisitive Voyager for a great idea.


Best Regards
Rick Osborn




________________________________
From: Inquisitive Voyager <hedonist2008@ gmail.com>
To: amibro...@yahoogrou ps.com
Sent: Fri, August 6, 2010 10:54:13 AM
Subject: Re: [amibroker] Multiple Higher Highs in Amibroker? [1 Attachment]

  
(1) find the attachment
(2) this code works in commentary window only.
(3)copy paste the code.dont overlay.


On Thu, Aug 5, 2010 at 7:29 PM, n7wyw <dennisljohnston@ hotmail.com> wrote:

  
>I want to find out the three highest highs for the past 100 periods. Highest 
>give only the top value, how can I get the next highest value and the next?
>
>Thanks,
>
>Dennis
>
>

 

Reply via email to