Help pls! Next Day End Close Order

 
Hello all,

I am trying to close opened order at the next day end. ie. suppose open order at 17/7,
then will close it at 18/7 day end or when touch stoploss. Can anyone help me with this
coding? It stucks me a few days. Thank a Lot!!

Nick
Reason: