run() is only called once per day at BarPeriod 1440, yet you’re checking for entry and exit conditions as if it’s an intraday script. Eliminate those conditions.