Ayone can of the Nth Lowest in AFL. I need the second lowest function. Thanks.
If you want to find Nth
lowest among last period
bars you can use Percentile function this way (the function assumes Nth counting starts from zero):
function NthLowest( array, Nth, period )
{
return Percentile( array, period, 100 * Nth / ( period - 1 ) );
}
if you wanted to start counting from one you would need this (obviously the only difference is just minus one):
function NthLowest( array, Nth, period )
{
return Percentile( array, period, 100 * (Nth-1) / ( period - 1 ) );
}
thank you very much. It has been a great help to me.
@Tomasz can you please double check this. Doesn't the order of your parameter arguments need to be the same in the function and in Percentile?
// switch order of "period" and "Nth"
function NthLowest( array, period, Nth )
{
return Percentile( array, period, 100 * Nth / ( period - 1 ) );
}
No, the function is correct. The order of period and nth arguments doesn't matter. If you want different order then do it but it does not change end result.
As for function arguments order...
Order would matter if you would write a DLL function via C/C++ ADK of AmiBroker.
Then order of types of function arguments is.... array, string, float
As aside NthHighest function has been posted few months ago (and same there... order of arguments doesn't matter).
No, it is YOUR user function and you can define YOUR function in any way you like including whatever parameter order you want.