Close Trade at end of day

script serves as an example how we can close trades at end of day.

can be session controlled or the time controlled.

the session should be adjusted to be earlier than the candle time.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?


After a lot of search, i finally got it from a fellow Indian trader. May you earn 10X this year.
+4 Reply
nice one sir
+3 Reply
When I tried this, its not working(not ending the the trade at the end of day), please guide if any changes required.
+1 Reply
ms30141 sudhakarreddyk
@sudhakarreddyk, I am not sure, but try changing your chart time resolution to 4-1 hour or even minute interval. It is not going to work with a day interval or lower time resolutions.
Thank you!
Great work. Works for me. Also, if we use minute time interval, then on line 95 and 98 we would write if ( hour(time) == 15 and minute(time) >= 59 )
Not working for me
Home Stock Screener Forex Screener Crypto Screener Economic Calendar About Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Referred friends Coins My Support Tickets Help Center Private Messages Chat Sign Out