I want to eliminate subsequent trade entry signals generated in other stocks in a group of stocks say 5 stocks that belong to the watch list of 50, if trade entry signal is generated in a particular stock that belong to that group of 5 stocks. I am struggling to code this idea. Any help is highly appreciated
The reason you are not getting responses is most likely because of ambiguity or lack of clarity.
Kindly read this Post and follow the guidelines for better response.
In a particular intra-day strategy that has a watch list of 50 stocks, I want to eliminate subsequent trade entry signals generated in other stocks in a group of stocks say 5 stocks that belong to the watch list of 50, if trade entry signal is generated in a particular stock that belong to that group of 5 stocks. These 5 stocks have a very high correlation in their price movement. So if stop loss is hit in any one of the 5 stocks, then there is a high probability that the stop loss will hit in the rest of the 4 stocks, if trades are generated in these stocks.
So I would like to enter into a trade in only one of the stocks in the group of 5, obviously the first one, along with the trades generated (if any) in rest of the 45 stocks in the watch list.
I would like to back test the idea to see the performance, but wonder how to code the elimination condition for back test.
This is conceptually the same as only wanting to trade N symbols from a particular sector. You might start by reading through this thread: Only different sectors. This is also similar to avoiding trades in highly correlated symbols, so you could search on that topic as well.
To really achieve what you want (only one open trade at a time from a predefined group of symbols), I believe you'll need to use a CBT. Use of the CBT is only recommended if you are already comfortable with AFL as well as how AmiBroker executes a 2-Phase backtest.