I have set my number of positions to 3 so thus I would expect to have 3 positions opened and closed every month. However, I often find that only 1 or 2 positions are opened. Why is that and how can I fix the problem?
It does work, however your buy and sell rules usually give signals at the same time (beginning of a month).
When a sell order is generated (sell at open of tomorrow) then a buy order to purchase the same stock is rejected.
Just add the following line to your trading system:
SetSimTiming(_Sell, _Close, -1); // Sell at close of today
OK, but that is not how I want to execute the system. I don't want to be out of the market overnight. Basically this system rebalances monthly. If I currently hold one position that will still be in the top3 the following month, I want rebalance it so that it gets 1/3 of the capital. I thought the easy way to do this was to sell all positions and then buy the top 3 with 100% of capital every month. I actually trade this system and accomplish this using MOC orders for both the buys and the sells in the lfirst day of the month. Maybe that is not the best way to execute the system due to commissions and slippage, but seems the easiest way to do the rebalancing.
Like I said, I'm accomplishing this using the SetSimLongRank command but it might be nice to tell the comp function whether to prioritize buy or sell orders vs. ignoring them when they happen at the same time.
Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.