Restore buy signal if it exceeds the limit of maximum open positions

I am writing a code to trade on moving average. I assign the buy signal as 1. However since it exceeds the limit of 10 maximum open positions, it does not take the trade. Is there any way that i can reset this signal to 0 in custom back test.

You can do whatever you want with that signal in the Custom Back Test (CBT). The question is, what are you trying to achieve?