Highest & Lowest Values across array

https://forum.amibroker.com/t/how-to-get-highest-open-interest-symbol-name-in-watchlist/6210

Although my requirement is a bit different from the one above, might be quiet similar in terms. I work on an options database with ticker further bifurcated as Underlying + Month + Strike + Opt-Type. The afl to run through is as posted below
Break

(Am appending my question at the end for flow purpose)

FilterParam=ParamStr("Mac/Mic/MWPL/Macb/Und","Mic");

Underticker = ParamStr( "Underlying", "NIFTY" );


startdate = ParamDate( "Start date", Now(0));
enddate = ParamDate( "End date", Now(0));
dn = datenum();
wd = DayOfWeek();
wdnum =LastValue(wd);
tuetosat = 0<wd>=6;
mon = wd==1;

datewindow = iif (tuetosat,dn >= startdate-1 AND dn <= enddate, dn>= startdate-3 AND dn <= enddate);


 _SECTION_BEGIN("Expiry Days");
Scrip=Name();
ScripF1=Scrip+"-I";
ScripF2=Scrip+"-II";
ScripF3=Scrip+"-III";
 
  _SECTION_BEGIN("Last Thursday");
function Lastthursday()
{
 Daysinmonth=IIf(Month()==1 OR Month()==3 OR Month()==5 OR Month()==7 OR Month()==8 OR Month()==10 OR Month()==12,31,30);
 Daysinmonthfeb=IIf(Year()%4 == 0 AND Year()%100!=0,29,28);
 Daysinmonthfinal=IIf(Month()==2,Daysinmonthfeb,Daysinmonth);
 returnvalue=IIf(Daysinmonthfinal-Day()<7 AND DayOfWeek()==4,1,0);
 return returnvalue;
}
 _SECTION_END();
 
 barssinceexpiry=BarsSince(Lastthursday());
 barssinceexpiry=IIf(Lastthursday(),1,barssinceexpiry);
 barssinceexpirynum = LastValue(barssinceexpiry);
 
BI = BarIndex(); 
nodcm =  barssinceexpiry;
nodlm = ValueWhen( Lastthursday(), BI, 1 ) - ValueWhen( Lastthursday(), BI, 2 ); 

 _SECTION_END();

 
 
 if(FilterParam=="Mac")
     { 
		
	_SECTION_BEGIN("Value Macro");

sym = Name(); 

ValString = StrRight(sym,7);
Valcondition = (ValString == "FUT-VAL");
ValStringBreak = StrRight(sym,9);
ValconditionBreak = (ValStringBreak != "I-FUT-VAL");


Underlying = StrExtract( sym, 0, '-'); 
if(Underlying=="BAJAJ")
{
Underlying = "BAJAJ-AUTO"; 
}
else if(Underlying=="MCDOWELL")
{
Underlying = "MCDOWELL-N"; 
}
else 
{
Underlying = StrExtract( sym, 0, '-'); 
}

FutSym = Underlying + "-FUT-VAL";
CESym = Underlying + "-CE-VAL";
PESym = Underlying + "-PE-VAL";


FutOI=Foreign(FutSym,"I");
FutVal=Foreign(FutSym,"C");

CallOI=Foreign(CESym,"I");
CallVal=Foreign(CESym,"C");

PutOI=Foreign(PESym,"I");
PutVal=Foreign(PESym,"C");

TotalOI = FutOI+CallOI+PutOI;
TotalVal = FutVal+CallVal+PutVal;

PCROI = PutOI/CallOI;
PCRVal = PutVal/CallVal;

FValEPer = (FutVal-Ref(FutVal,-barssinceexpirynum))/Ref(FutVal,-barssinceexpirynum)*100;
CallValEPer = (CallVal-Ref(CallVal,-barssinceexpirynum))/Ref(CallVal,-barssinceexpirynum)*100;
PutValEPer = (PutVal-Ref(PutVal,-barssinceexpirynum))/Ref(PutVal,-barssinceexpirynum)*100;
TotalValEPer = (TotalVal-Ref(TotalVal,-barssinceexpirynum))/Ref(TotalVal,-barssinceexpirynum)*100;

SetOption("NoDefaultColumns", True );

Filter= Valcondition AND ValconditionBreak AND datewindow;

 Blank = "$";
AddTextColumn(Underlying,"Underlying");
AddTextColumn(Date(),"Date");
AddTextColumn(Blank,"$");
AddColumn(FutOI,"FOI",1.0);
AddColumn(Ref(FutOI,-1),"FOI-1",1.0);
AddColumn(ROC(FutOI,1),"FOI%");
AddColumn(FutVal,"FVal");
AddColumn(Ref(FutVal,-1),"FVal-1");
AddColumn(FutVal-Ref(FutVal,-1),"FVal Diff");
AddColumn(ROC(FutVal,1),"FVal%");
AddColumn(Ref(FutVal,-barssinceexpirynum),"FValE");
AddColumn(FutVal-Ref(FutVal,-barssinceexpirynum),"FValE Diff");
AddColumn(FValEPer,"FValE%");
AddTextColumn(Blank,"$");
AddColumn(CallOI,"CE-OI",1.0);
AddColumn(Ref(CallOI,-1),"CE-OI-1",1.0);
AddColumn(ROC(CallOI,1),"CE-OI%");
AddColumn(CallVal,"CE-Val");
AddColumn(Ref(CallVal,-1),"CE-Val-1");
AddColumn(CallVal-Ref(CallVal,-1),"Call Val Diff");
AddColumn(ROC(CallVal,1),"CE-Val%");
AddColumn(Ref(CallVal,-barssinceexpirynum),"CallValE");
AddColumn(CallVal-Ref(CallVal,-barssinceexpirynum),"CallValE Diff");
AddColumn(CallValEPer,"CallValE%");
AddTextColumn(Blank,"$");
AddColumn(PutOI,"PE-OI",1.0);
AddColumn(Ref(PutOI,-1),"PE-OI-1",1.0);
AddColumn(ROC(PutOI,1),"PE-OI%");
AddColumn(PutVal,"PE-Val");
AddColumn(Ref(PutVal,-1),"PE-Val-1");
AddColumn(PutVal-Ref(PutVal,-1),"Put Val Diff");
AddColumn(ROC(PutVal,1),"PE-Val%");
 AddColumn(Ref(PutVal,-barssinceexpirynum),"PutValE");
AddColumn(PutVal-Ref(PutVal,-barssinceexpirynum),"PutValE Diff");
AddColumn(PutValEPer,"PutValE%");
 AddTextColumn(Blank,"$");
AddColumn(TotalOI,"Tot-OI");
AddColumn(Ref(TotalOI,-1),"Tot-OI-1");
AddColumn(ROC(TotalOI,1),"Tot-OI%");
AddColumn(TotalVal,"Tot-Val");
AddColumn(Ref(TotalVal,-1),"Tot-Val-1");
AddColumn(TotalVal-Ref(TotalVal,-1),"Total Val Diff");
AddColumn(ROC(TotalVal,1),"Tot-Val%");
AddColumn(Ref(TotalVal,-barssinceexpirynum),"TotalValE");
AddColumn(TotalVal-Ref(TotalVal,-barssinceexpirynum),"TotalValE Diff");
AddColumn(TotalValEPer,"TotalValE%");
AddTextColumn(Blank,"$");
AddColumn(PCROI,"PCR-OI",1.4); 
AddColumn(Ref(PCROI,-1),"PCR-OI-1",1.4); 
AddColumn(ROC(PCROI,1),"PCR-OI%",1.2); 
AddColumn(PCRVal,"PCR-Val",1.4); 
AddColumn(Ref(PCRVal,-1),"PCR-Val-1",1.4); 
AddColumn(ROC(PCRVal,1),"PCR-Val%",1.2); 

 SetSortColumns( 1 ); 
 
_SECTION_END();
	
		
	 }
	 
else  if(FilterParam=="Macb")

{ 
		
_SECTION_BEGIN("Value Macro Breakup");

sym = Name(); 

ValString = StrRight(sym,7);
Valcondition = (ValString == "FUT-VAL");
ValStringBreak = StrRight(sym,9);
ValconditionBreak = (ValStringBreak == "I-FUT-VAL");

Underlying = StrExtract( sym, 0, '-'); 
MonOfExpiry = StrExtract( sym, 1, '-'); 
if(Underlying=="BAJAJ")
{
Underlying = "BAJAJ-AUTO"; 
MonOfExpiry = StrExtract( sym, 2, '-'); 
StrikeChar = StrExtract( sym, 3, '-'); 
OptType = StrExtract( sym, 4, '-');
Strike = StrToNum( StrExtract( sym, 3, '-') );
UnderlyingType = Underlying +"-"+OptType;
}

else if(Underlying=="MCDOWELL")
{
Underlying = "MCDOWELL-N"; 
MonOfExpiry = StrExtract( sym, 2, '-'); 
StrikeChar = StrExtract( sym, 3, '-'); 
OptType = StrExtract( sym, 4, '-');
Strike = StrToNum( StrExtract( sym, 3, '-') );
UnderlyingType = Underlying +"-"+OptType;
}

else
{
Underlying = StrExtract( sym, 0, '-'); 
}

FutSym = Underlying + "-"+MonOfExpiry+"-FUT-VAL";
CESym = Underlying + "-"+MonOfExpiry+"-CE-VAL";
PESym = Underlying + "-"+MonOfExpiry+"-PE-VAL";


FutOI=Foreign(FutSym,"I");
FutVal=Foreign(FutSym,"C");

CallOI=Foreign(CESym,"I");
CallVal=Foreign(CESym,"C");

PutOI=Foreign(PESym,"I");
PutVal=Foreign(PESym,"C");

TotalOI = FutOI+CallOI+PutOI;
TotalVal = FutVal+CallVal+PutVal;

PCROI = PutOI/CallOI;
PCRVal = PutVal/CallVal;

FValEPer = (FutVal-Ref(FutVal,-barssinceexpirynum))/Ref(FutVal,-barssinceexpirynum)*100;
CallValEPer = (CallVal-Ref(CallVal,-barssinceexpirynum))/Ref(CallVal,-barssinceexpirynum)*100;
PutValEPer = (PutVal-Ref(PutVal,-barssinceexpirynum))/Ref(PutVal,-barssinceexpirynum)*100;
TotalValEPer = (TotalVal-Ref(TotalVal,-barssinceexpirynum))/Ref(TotalVal,-barssinceexpirynum)*100;


SetOption("NoDefaultColumns", True );

Filter= ValconditionBreak AND datewindow ;

 Blank = "$";
AddTextColumn(Underlying+"-"+MonOfExpiry,"Underlying");
AddTextColumn(Date(),"Date");
AddTextColumn(Blank,"$");
AddColumn(FutOI,"FOI",1.0);
AddColumn(Ref(FutOI,-1),"FOI-1",1.0);
AddColumn(ROC(FutOI,1),"FOI%");
AddColumn(FutVal,"FVal");
AddColumn(Ref(FutVal,-1),"FVal-1");
AddColumn(FutVal-Ref(FutVal,-1),"Fut Val Diff");
AddColumn(ROC(FutVal,1),"FVal%");
AddColumn(Ref(FutVal,-barssinceexpirynum),"FValE");
AddColumn(FutVal-Ref(FutVal,-barssinceexpirynum),"FValE Diff");
AddColumn(FValEPer,"FValE%");
AddTextColumn(Blank,"$");
AddColumn(CallOI,"CE-OI",1.0);
AddColumn(Ref(CallOI,-1),"CE-OI-1",1.0);
AddColumn(ROC(CallOI,1),"CE-OI%");
AddColumn(CallVal,"CE-Val");
AddColumn(Ref(CallVal,-1),"CE-Val-1");
AddColumn(CallVal-Ref(CallVal,-1),"Call Val Diff");
AddColumn(ROC(CallVal,1),"CE-Val%");
AddColumn(Ref(CallVal,-barssinceexpirynum),"CallValE");
AddColumn(CallVal-Ref(CallVal,-barssinceexpirynum),"CallValE Diff");
AddColumn(CallValEPer,"CallValE%");
AddTextColumn(Blank,"$");
AddColumn(PutOI,"PE-OI",1.0);
AddColumn(Ref(PutOI,-1),"PE-OI-1",1.0);
AddColumn(ROC(PutOI,1),"PE-OI%");
AddColumn(PutVal,"PE-Val");
AddColumn(Ref(PutVal,-1),"PE-Val-1");
AddColumn(PutVal-Ref(PutVal,-1),"Put Val Diff");
AddColumn(ROC(PutVal,1),"PE-Val%");
AddColumn(Ref(PutVal,-barssinceexpirynum),"PutValE");
AddColumn(PutVal-Ref(PutVal,-barssinceexpirynum),"PutValE Diff");
AddColumn(PutValEPer,"PutValE%"); 
 AddTextColumn(Blank,"$");
AddColumn(TotalOI,"Tot-OI");
AddColumn(Ref(TotalOI,-1),"Tot-OI-1");
AddColumn(ROC(TotalOI,1),"Tot-OI%");
AddColumn(TotalVal,"Tot-Val");
AddColumn(Ref(TotalVal,-1),"Tot-Val-1");
AddColumn(TotalVal-Ref(TotalVal,-1),"Total Val Diff");
AddColumn(ROC(TotalVal,1),"Tot-Val%");
AddColumn(Ref(TotalVal,-barssinceexpirynum),"TotalValE");
AddColumn(TotalVal-Ref(TotalVal,-barssinceexpirynum),"TotalValE Diff");
AddColumn(TotalValEPer,"TotalValE%");
AddTextColumn(Blank,"$");
AddColumn(PCROI,"PCR-OI",1.4); 
AddColumn(Ref(PCROI,-1),"PCR-OI-1",1.4); 
AddColumn(ROC(PCROI,1),"PCR-OI%",1.2); 
AddColumn(PCRVal,"PCR-Val",1.4); 
AddColumn(Ref(PCRVal,-1),"PCR-Val-1",1.4); 
AddColumn(ROC(PCRVal,1),"PCR-Val%",1.2); 

 SetSortColumns( 1 ); 
 
_SECTION_END();
	
		
	 }
	 
else  if(FilterParam=="Mic")  
    {   
		
		_SECTION_BEGIN("Value Micro");

sym = Name(); 

Underlying = StrExtract( sym, 0, '-'); 
MonOfExpiry = StrExtract( sym, 1, '-'); 
StrikeChar = StrExtract( sym, 2, '-'); 
OptType = StrExtract( sym, 3, '-');
Strike = StrToNum( StrExtract( sym, 2, '-') );
UnderlyingType = Underlying +"-"+OptType;

if(Underlying=="BAJAJ")
{
Underlying = "BAJAJ-AUTO"; 
MonOfExpiry = StrExtract( sym, 2, '-'); 
StrikeChar = StrExtract( sym, 3, '-'); 
OptType = StrExtract( sym, 4, '-');
Strike = StrToNum( StrExtract( sym, 3, '-') );
UnderlyingType = Underlying +"-"+OptType;
}

else if(Underlying=="MCDOWELL")
{
Underlying = "MCDOWELL-N"; 
MonOfExpiry = StrExtract( sym, 2, '-'); 
StrikeChar = StrExtract( sym, 3, '-'); 
OptType = StrExtract( sym, 4, '-');
Strike = StrToNum( StrExtract( sym, 3, '-') );
UnderlyingType = Underlying +"-"+OptType;
}

OIVal = OI*Strike/10000000;
OIVal1 = Ref(OIVal,-1);

ValString = StrRight(sym,4);
Valcondition = (ValString != "-VAL") AND (MonOfExpiry != "EXC") AND (MonOfExpiry != "MWPL");

R=Strike + Aux1;
S=Strike-Aux1;

R5 = Strike + EMA(Aux1,5);
S5 = Strike - EMA(Aux1,5);
R10 = Strike + EMA(Aux1,10);
S10 = Strike - EMA(Aux1,10);
R15 = Strike + EMA(Aux1,15);
S15 = Strike - EMA(Aux1,15);
R20 = Strike + EMA(Aux1,20);
S20 = Strike - EMA(Aux1,20);

RS = IIf(OptType =="CE",R,S);
RS5 = IIf(OptType =="CE",R5,S5);
RS10 = IIf(OptType =="CE",R10,S10);
RS15 = IIf(OptType =="CE",R15,S15);
RS20 = IIf(OptType =="CE",R20,S20);

Filter= Valcondition AND datewindow ;

OValEPer=(OIVal-Ref(OIVal,-barssinceexpirynum))/Ref(OIVal,-barssinceexpirynum)*100;

SetOption("NoDefaultColumns", True );

 Blank = "$";
  AddTextColumn(Underlying,"Under");
 AddTextColumn(Date(),"Date");
  AddTextColumn(MonOfExpiry,"Month");
 AddColumn(Strike,"Strike Num");
 AddTextColumn(OptType,"OType");
 AddTextColumn(Blank,"$");
 AddColumn(C,"Prem");
 AddColumn(Aux1,"ATP");
 AddColumn(RS,"RS");

 AddColumn(OI,"OI",1.0);
 AddColumn(Ref(OI,-1),"OI-1",1.0);
 AddColumn(OIVal,"OVal",1.2); 
 AddColumn(Ref(OIVal,-1),"OVal-1",1.2);
 AddColumn(OIVal-OIVal1,"OValDiff",1.2);
AddColumn(ROC(OIVal,1),"OVal%",1.2);

AddColumn(Ref(OIVal,-barssinceexpirynum),"OValE",1.2);
AddColumn(OIVal-Ref(OIVal,-barssinceexpirynum),"OValDiffE",1.2);
AddColumn(OValEPer,"OValE%",1.2);

AddTextColumn(Blank,"$");
AddColumn(RS5,"RS5");
AddColumn(RS10,"RS10");
AddColumn(RS15,"RS15");
AddColumn(RS20,"RS20");

 
 SetSortColumns( 1 ); 
 
 
_SECTION_END();
		
     }
   
else  if(FilterParam=="Und")  
    {   
		
		_SECTION_BEGIN("Value Micro on Underlying");

sym = Name(); 


Underlying = StrExtract( sym, 0, '-'); 
MonOfExpiry = StrExtract( sym, 1, '-'); 
StrikeChar = StrExtract( sym, 2, '-'); 
OptType = StrExtract( sym, 3, '-');
Strike = StrToNum( StrExtract( sym, 2, '-') );
UnderlyingType = Underlying +"-"+OptType;

if(Underlying=="BAJAJ")
{
Underlying = "BAJAJ-AUTO"; 
MonOfExpiry = StrExtract( sym, 2, '-'); 
StrikeChar = StrExtract( sym, 3, '-'); 
OptType = StrExtract( sym, 4, '-');
Strike = StrToNum( StrExtract( sym, 3, '-') );
UnderlyingType = Underlying +"-"+OptType;
}

else if(Underlying=="MCDOWELL")
{
Underlying = "MCDOWELL-N"; 
MonOfExpiry = StrExtract( sym, 2, '-'); 
StrikeChar = StrExtract( sym, 3, '-'); 
OptType = StrExtract( sym, 4, '-');
Strike = StrToNum( StrExtract( sym, 3, '-') );
UnderlyingType = Underlying +"-"+OptType;
}

OIVal = OI*Strike/10000000;
OIVal1 = Ref(OIVal,-1);

ValString = StrRight(sym,4);
Valcondition = (ValString != "-VAL") AND (MonOfExpiry != "EXC") AND (MonOfExpiry != "MWPL");


R=Strike + Aux1;
S=Strike-Aux1;

R5 = Strike + EMA(Aux1,5);
S5 = Strike - EMA(Aux1,5);
R10 = Strike + EMA(Aux1,10);
S10 = Strike - EMA(Aux1,10);
R15 = Strike + EMA(Aux1,15);
S15 = Strike - EMA(Aux1,15);
R20 = Strike + EMA(Aux1,20);
S20 = Strike - EMA(Aux1,20);

RS = IIf(OptType =="CE",R,S);
RS5 = IIf(OptType =="CE",R5,S5);
RS10 = IIf(OptType =="CE",R10,S10);
RS15 = IIf(OptType =="CE",R15,S15);
RS20 = IIf(OptType =="CE",R20,S20);


Filter= Valcondition AND Underlying==Underticker AND datewindow ;


OValEPer=(OIVal-Ref(OIVal,-barssinceexpirynum))/Ref(OIVal,-barssinceexpirynum)*100;

SetOption("NoDefaultColumns", True );

 Blank = "$";
  AddTextColumn(Underlying,"Under");
 AddTextColumn(Date(),"Date");
  AddTextColumn(MonOfExpiry,"Month");
 AddColumn(Strike,"Strike Num");
 AddTextColumn(OptType,"OType");
 AddTextColumn(Blank,"$");
 AddColumn(C,"Prem");
 AddColumn(RS,"RS");
 AddColumn(OI,"OI",1.0);
 AddColumn(Ref(OI,-1),"OI-1",1.0);
 AddColumn(OIVal,"OVal",1.2);
  AddColumn(Ref(OIVal,-1),"OVal-1",1.2);
 AddColumn(OIVal-OIVal1,"OValDiff",1.2);
AddColumn(ROC(OIVal,1),"OVal%",1.2);
AddColumn(Ref(OIVal,-barssinceexpirynum),"OValE",1.2);
AddColumn(OIVal-Ref(OIVal,-barssinceexpirynum),"OValDiffE",1.2);
AddColumn(OValEPer,"OValE%",1.2);
AddTextColumn(Blank,"$");
AddColumn(RS5,"RS5");
AddColumn(RS10,"RS10");
AddColumn(RS15,"RS15");
AddColumn(RS20,"RS20");

 SetSortColumns( 1 ); 
 
 
_SECTION_END();


		
     }

else  if(FilterParam=="MWPL")  
{   
		
_SECTION_BEGIN("MWPL");

sym = Name(); 


EXCOIString = StrRight(sym,7);
EXCOIcondition = (EXCOIString == "-EXC-OI");
MWPLString = StrRight(sym,5);
MWPLcondition = (MWPLString == "-MWPL");

 

Filter= MWPLcondition AND datewindow ;


Underlying = StrExtract( sym, 0, '-'); 
MonOfExpiry = StrExtract( sym, 1, '-'); 
StrikeChar = StrExtract( sym, 2, '-'); 
OptType = StrExtract( sym, 3, '-');
Strike = StrToNum( StrExtract( sym, 2, '-') );
UnderlyingType = Underlying +"-"+OptType;

if(Underlying=="BAJAJ")
{
Underlying = "BAJAJ-AUTO"; 
MonOfExpiry = StrExtract( sym, 2, '-'); 
StrikeChar = StrExtract( sym, 3, '-'); 
OptType = StrExtract( sym, 4, '-');
Strike = StrToNum( StrExtract( sym, 3, '-') );
UnderlyingType = Underlying +"-"+OptType;
}

else if(Underlying=="MCDOWELL")
{
Underlying = "MCDOWELL-N"; 
MonOfExpiry = StrExtract( sym, 2, '-'); 
StrikeChar = StrExtract( sym, 3, '-'); 
OptType = StrExtract( sym, 4, '-');
Strike = StrToNum( StrExtract( sym, 3, '-') );
UnderlyingType = Underlying +"-"+OptType;
}

EXCOISym = Underlying + "-EXC-OI";
MWPLSym = Underlying + "-MWPL";


EXCOI= Foreign(EXCOISym,"C"); 

HHVEXCOI = HHV(EXCOI,barssinceexpirynum);
HHVOIDiff = EXCOI-HHVEXCOI;
HHVOIPer = HHVOIDiff /HHVEXCOI;

LLVEXCOI = LLV(EXCOI,barssinceexpirynum);
LLVOIDiff = EXCOI-LLVEXCOI;
LLVOIPer = LLVOIDiff /LLVEXCOI;

HHD = Ref( DateTime(), -HHVBars(EXCOI,barssinceexpirynum) );
LLD = Ref( DateTime(), -LLVBars( EXCOI,barssinceexpirynum ) );

MWPL = Foreign(MWPLSym,"C"); 

MWPLRatio =ValueWhen( EXCOI != 0,EXCOI )/ValueWhen( MWPL != 0,MWPL )*100;
HHVMWPL = HHV(MWPLRatio,barssinceexpirynum);
LLVMWPL = LLV(MWPLRatio,barssinceexpirynum);

ROCEXCOI = (EXCOI-Ref(EXCOI,-barssinceexpirynum))/Ref(EXCOI,-barssinceexpirynum)*100;

SetOption("NoDefaultColumns", True );

 Blank = "$";
AddTextColumn(Underlying,"Under");
AddTextColumn(Date(),"Date");
AddTextColumn(Blank,"$");
AddColumn(MWPL,"MWPL",1.0);
AddColumn(EXCOI,"EX-OI",1.0);
AddColumn(ROC(EXCOI,1),"EX-OI%",1.2);
AddColumn(Ref(EXCOI,-1),"EX-OI-1",1.0);
AddColumn(ROCEXCOI,"EX-Exp-OI%",1.2);
AddColumn(Ref(EXCOI,-barssinceexpirynum),"EX-Exp-OI",1.0);
AddColumn(MWPLRatio,"MWPLRatio");
AddColumn(HHVEXCOI,"HIGH OI",1.0);
AddColumn( HHD, "Date of Year High", formatDateTime ); 
AddColumn(HHVMWPL,"HIGH Ratio");
AddColumn(HHVOIDiff,"HIGH Difference",1.0);
AddColumn(HHVOIPer,"HIGH Per");
AddColumn(LLVEXCOI,"LOW OI",1.0);
AddColumn( LLD, "Date of Year Low", formatDateTime ); 
AddColumn(LLVMWPL,"LOW Ratio");
AddColumn(LLVOIDiff,"LOW Difference",1.0);
AddColumn(LLVOIPer,"LOW Per");

 SetSortColumns( 1 ); 
 
 
_SECTION_END();

}

Like in excel & or Vb, I wish to find the highest open interest for a give underlying across all the tickers for a given single bar & then correspondingly find the strike corresponding to it. Thus it would be a summary of the highest open interest from 1st to the 5th instance. In excel I am using the LARGE function like "=LARGE(IF(Micro!$E:$E="CE",IF(Micro!$C:$C="I",IF(Micro!$A:$A=I6,Micro!$J:$J))),1)", as depicted in screenshot below

Excel

To find first largest value in array simply use Highest function http://www.amibroker.com/f?highest

To display highest and lowest value from exploration column use AddSummaryRow
http://www.amibroker.com/guide/afl/addsummaryrows.html

Errata : Please read the para as follows