I made a few small changes to your code that were discussed above, which improve returns for the periods I tested. The beta values on this are still very high - way too high for the Q fund , but perhaps not for an aggressive trader.
My suggestion for improvement would be to cause a reset on THAT PARTICULAR STOCK, whenever the stock reaches a 3 fold standard deviation.
Right now the stocks initial direction (long or short) stays in that direction permanently so the stock will
only ever be traded in that direction. So if it drops 40 percent it will never go long again until that 40 percent breach is recovered. This could be improved upon , I believe. Theoretically you might want to consider going long again when it has dropped by at least 2/3 of the previous long term high low.
So for example if stock has gone up by 3 standard deviations, you might want to reset the dump_price and more_price values for that stock once the stock has regressed back to its mean
Obviously this would need to be tested to determine if it really helps.
Can you point me to the original website espousing this scaled trading methodology?