hi guys,
i am developing a strategy, this strategy will filter a watchlist based on the performance ranking system using the matrix function. Then the buy and sell signals will be applied to this watchlist.
The problem is that i can't test this system using explorer, when i select from-to-date, it only works if the start date and end date are the same. If i select a time period, it will only calculate based on the watchlist created on the end date.
Is there any way to fix this problem
tickerlist = CategoryGetSymbols( categoryWatchlist, 0 );
sym_num = StrCount(tickerlist, ",")+1;
mat = Matrix(sym_num, 2);
for ( i = 0; ( symbol = StrExtract( TickerList, i ) ) != ""; i++ )
{
SetForeign(symbol);
fc = C;
Vol = V;
VolTB = MA(V,50);
RestorePriceArrays();
fc = SelectedValue(fc);
VolTB = SelectedValue(VolTB);
GTGD = fC*VolTB;
mat[i][0] = i;
mat[i][1] = GTGD;
}
mat0 = MxSortRows(mat, False, 1); //sort GTGD value
sym_list = "";
topkl = sym_num*0.1;
for ( i = 0; i < topkl ; i++ ) //Top 10% symbols
{
n0 = mat0[i][0];
symbol = StrExtract(tickerlist, n0);
sym_list += symbol+",";
}
sym_list = StrTrim( sym_list, ",", 2 ); // trim separator at the end
//assign new matrix
mat1 = Matrix(topkl,5);
for ( i = 0; ( symbol = StrExtract( sym_list, i ) ) != ""; i++ )
{
SetForeign(symbol);
roc1 = ROC(C,10);
roc2 = ROC(C,20);
roc3 = ROC(C,65);
roc4 = ROC(C,125);
barabovema50 = BarsSince(Close < EMA(Close,50));
RestorePriceArrays();
if (SelectedValue(roc1) > 0 AND SelectedValue(roc2) > 5 AND
SelectedValue(roc3) > 20 AND SelectedValue(roc4) > 5 AND
SelectedValue(barabovema50) >= 20)
{
mat1[i][0] = i;
mat1[i][1] = SelectedValue(roc1);
mat1[i][2] = SelectedValue(roc2);
mat1[i][3] = SelectedValue(roc3);
mat1[i][4] = SelectedValue(roc4);
}
}
mat2 = MxSortRows(mat1, False, 1);
toplist = "";
topn = 15;
for ( i = 0; i < topn AND i < sym_num; i++ )
{
n2 = mat2[i][0]; roc1 = mat2[i][1];
symbol = StrExtract(sym_list, n2);
toplist += symbol+",";
}
toplist = StrTrim( toplist, ",", 2 );
toplist = StrSort(toplist);
toplist_num = StrCount(toplist, ",")+1;
Buy = cross(Close, Ref(HHV(C,20),-1)) AND StrFind(toplist,Name());
Filter = Buy;
AddColumn(C*MA(V,50),"GTGD",1.0);