When I simulate strategies, I sometimes can not estimate profitability automatically, because on last bar strategy contains open trades.
I can of course calculate such unclosed strategy profit manually. However, it looks better idea to close strategy on last bar automatically when I debugging it.
I don't want to set process_orders_on_closed to still have realistic result. I just need to initiate close_all on penultimate bar, so on last bar it will close the order with previous bar close price.
Is there a way to do that with Pine Script, or I need more serious programming environment than Pine Script for such customization?