# afl code - highest and second highest close between two dates

#### garry_gc

##### New Member
hi,
can any one help me to find out highest and second highest closing price between date range in amibroker ( afl coding).

.

Last edited:

#### AmiFan

##### New Member
raj_jain you are trying to steal someone else's thread (your post has NOTHING to do with the title of this thread) and you are posting the exact same request on multiple threads! Stop being so selfish and inconsiderate.

#### AmiFan

##### New Member
// Try this. Works on finding highest highs between the dates you choose in the Analysis "to" and "from" dates
// Status("barinrange") - returns 1 when current bar is within current auto-analysis From-To range

Period = EndValue( Cum( Status( "barinrange" ) ) ); // LastValue gives a number instead of an array, needed in Percentile function

function NthHV( array, period, nth )
{
return Percentile( array, period, ( period - nth ) / ( period - 1 ) * 100 );
}

HighestValue = HHV( H, Period );
SecondHighest = NthHV( H, period, 2 );

Last edited:

#### trash

##### Well-Known Member
// Try this. Works on finding highest highs between the dates you choose in the Analysis "to" and "from" dates
// Status("barinrange") - returns 1 when current bar is within current auto-analysis From-To range

Period = EndValue( Cum( Status( "barinrange" ) ) ); // LastValue gives a number instead of an array, needed in Percentile function

function NthHV( array, period, nth )
{
return Percentile( array, period, ( period - nth ) / ( period - 1 ) * 100 );
}

HighestValue = HHV( H, Period );
SecondHighest = NthHV( H, period, 2 );
It is not you who came up with that. So what we have here is another guy trying to adorn himself with borrowed plumes.

#### garry_gc

##### New Member
dear trash,
i don't know why are you so possessive. there is a idioms " khali hath aye the ,khali hath jana hai".
you better understand what i mean.

#### garry_gc

##### New Member
Dear AmiFan,
I really appreciate your effort, i think this will work for me, let me check on ami and get back to you,

#### AmiFan

##### New Member
It is not you who came up with that. So what we have here is another guy trying to adorn himself with borrowed plumes.
I didn't say that I came up with it, I just listed it as a possible solution to the question to help garry_gc

I would usually just post a link to something but in this case I made a small change to the code to answer the poster's question since the original link wasn't exactly what I thought he asked for. If you had wanted to help that's great, but the question had been waiting for weeks. And you made no effort to help.

If you post code on Internet then you should expect it to get used. If you don't like it then stop posting code on Internet.

Last edited:

#### AmiFan

##### New Member
Dear AmiFan,
I really appreciate your effort, i think this will work for me, let me check on ami and get back to you,