// Downloaded From https://www.WiseStockTrader.com
_SECTION_BEGIN("Relative PERFORMANCE IDX SECTORAL");
NamaWatchlist = ParamStr("MASUKKAN NAMA WatchList ", "List 0");
jumlahWatchlist = CategoryFind(NamaWatchlist, cat = categoryWatchlist); 
Daftarticker = Name() + "," + CategoryGetSymbols(cat, jumlahWatchlist);
fontsize = Param("Label font size", 10, 4, 30, 1 );
bi = BarIndex();
fbr = Status("firstbarinrange");
Filter = Status("barinrange");
explore = Status("action") == actionExplore;
fvb = IIf(explore, LastValue(ValueWhen(fbr,bi)), Status("firstvisiblebar"));
mat = Matrix(StrCount(Daftarticker, ",")+1, 2);
jumlahrow = MxGetSize(mat, 0);
for ( i = 0; ( symbol = StrExtract(Daftarticker, i ) ) != ""; i++ ) {
 fc = Foreign( symbol, "C" ); 
 idx = Max(NullCount(fc), fvb);
 if (! IsNull(fc[ idx ])) {
  idxsectoral = 100 * (fc - fc[ idx ]) / fc[ idx ];   
  mat[i][0] = SelectedValue(idxsectoral); 
  mat[i][1] = i;   
  x = LastValue(bi) + 1;
  y = LastValue(idxsectoral);
  VarSet("color"+i, colorLightOrange + ((2*i)%15));      
  AddColumn(idxsectoral, "RS-"+symbol, 1.2, color = Varget("color"+i));     
  Plot(idxsectoral, "\n"+symbol, color, styleNoLabel | styleNoTitle);        
  PlotTextSetFont(symbol, "Arial", fontsize, x, y, GetChartBkColor(), color, -fontsize/2);
 }
}

PlotGrid( 0, colorYellow );
Param_dt = FirstVisibleValue(DateTime());
_N(Title = StrFormat( "WATCHLIST(%g): %s, {{NAME}} - Tanggal di mulai: %s, Relative Idx Sectoral [%%]: {{VALUES}}", 
      jumlahWatchlist, NamaWatchlist, DateTimeToStr(Param_dt, 1))); 
SetChartOptions(0, chartWrapTitle);

mat = MxSortRows(mat, False, 0);

for ( i = 0; i < jumlahrow; i++ ) {
 val = mat[i][0]; n = mat[i][1];
 if (! IsNull(val)) {  
  sym = StrExtract(Daftarticker, n);
  color = EncodeColor(Nz(Varget("color"+n)));
  Title += StrFormat("\n%s %s: %g", color,sym,val);  
 }
}
_SECTION_END();