Dear UB,
also make some code to avoid some scrips from output manually which is from same sector...eg today 3 top scrips in nifty 50 is from banking....if we increase scrip nos and avoid some scrips its allocation also coming diferent...eg if I trade with 3 scrips ....if I skip 1 or 2 for it and use next 2 scrips using 5scrips output alocation are spreads in for 5 scrips not for 3 scrips....Hope you understand what I explained...
Diversfying different sectors is a good strategy (H2D does it but the code is a bit complex so I am holding it back).
Regarding number of scrips, I think the strategy would adjust the allocation based on capital. So in case of 1 stock, the entire capital would be allocated if case of 2 it would be split into half and so on.
Also, in case of skipping we must be consistent with the rules of skipping such as skip the stock if its up by 10% or skip it if the preopen return is in negative and so on.
Could you provide an example?