Please provide me Code to back test "exit long/short" positions by end of same day (MIS) automatically on daily charts (not minute or hour charts)

you can provide your condition or you can check the scripts with syntax's , go to help-> tradescript help in pi

there are EA's which is available  and you can make use of it