A simple indicator code for learners which may also help you in manual backtest by just moving a vertical line to show hide bars.
Add the indicator to chart and Add a Vertical Line object with name “VL” and it will start working on Oncalculate()
You can move the line to left or right on chart and it will hide bars on right side