Pine Script Entry And Close On Same Bar Causing Error Uncaught Error Value Is Null Stack

Pine Script Entry And Close On Same Bar Causing Error Uncaught Error Value Is Null Stack