var Weights[30];
var SharpeVariance = markowitz(Covariances,Means,N);
markowitzReturn(Weights,SharpeVariance);
// change the portfolio composition according to new weights
for(i=0; i<N; i++){
asset(Names[i]);
int NewLots = TotalCapital*Weights[i]/MarginCost;
if(NewLots > OldLots[i])
enterLong(NewLots-OldLots[i]);
else if(NewLots < OldLots[i])
exitLong(0,0,OldLots[i]-NewLots);
OldLots[i] = NewLots;
}