Hi,
I'm new to the community and seeking some advice.
I’m working on limiting the number of re-entries per symbol per day in an intraday portfolio backtest. I currently use ApplyStop
to manage stop-losses, as shown below:
ApplyStop(stopTypeLoss, stopModePoint, stopAmountShort, 1);
I found this knowledge base article that outlines three methods to achieve this, but I’ve run into issues with each:
- Option 1:
This method doesn’t suppress consecutive signals like short-short-short-cover. For example, suppose signals are generated at 8:30, 8:31, and 8:32, with an entry at 8:30 and an exit at 9:00. The counter counts all signals (3 in this case), which prevents re-entry after the exit at 9:00 if the limit is set to 3. - Option 2: Using
Equity(1)
:
TheEquity()
function is described as a "single-security backtester-in-a-box." I tried using it but encountered unexpected results. Since it seems intended for single-security backtesting, I didn’t dive deeper. If my understanding is incorrect, please let me know—I’d be happy to share my code and findings. - Option 3:
This approach works but has a limitation: when stops are triggered, thecover
variable is not set to 1, preventing new positions from being initiated.
Additionally, I tried using SetMaxOpenPosition
, but it didn’t work for my use case. My scenario involves trading on n
different stocks each day, with a limit of m
entries per stock. Since I don’t know the value of n
in advance, this method would allow a single stock to take more trades than intended (as long as the total trade count across all stocks stays within the limit of m * n
).
Given these challenges, I’m considering a couple of alternative approaches:
- Would it make sense to create a custom backtester to better handle this scenario?
- Alternatively, should I look into managing stop-losses manually without relying on
ApplyStop
?
Any suggestions or guidance on this issue would be greatly appreciated.
Thank you!