Time-Based Alerts in TradingView: Flatten at a Set Time Every Day
Go flat in an instant with a TradingView webhook and this a simple Time-based Alert Indicator.
At CrossTrade we're constantly implementing good ideas from our users and when we were asked the following:
Is there a way to have the programs close all positions at a specified cut off time? I see that it has the ability to stop new trades and close on the next reversal but curious if I set it to close all at 3:30 pm if it has that ability? Prop firms have cut off times so don’t want it to go past the time if a reversal signal doesn’t come out
There was an obvious solution. Introducing the Time-based Alert Indicator...

Primary Functionality
This is a simple utility indicator is designed to trigger alerts at a specific time each day. The user can configure the alert at the End Of Day time they elect to tell NinjaTrader its time to go flat.
User-Defined Alert Time:
Users can specify the exact hour and minute when they want the alert to trigger. The inputs i_hour and i_minute allow the user to set these values, with hour options ranging from 0 to 23 and minute options from 0 to 59.
Time Zone Selection:
The script offers a choice between Eastern Time (New York) and Central Time (Chicago) through the use_central_time boolean input. Depending on the selected time zone, the script adjusts the time accordingly to ensure the alert triggers at the correct time.
Alert Trigger Mechanism:
The script checks the current time against the user-defined alert time. If the current hour and minute match the specified values, an alert condition is activated (alert_condition).
Visual Feedback:
For debugging and verification purposes, the script displays the current time on the chart using a label. This label updates in real-time to show the current hour and minute based on the selected time zone.

Additionally, when the alert condition is met, a yellow triangle shape is plotted below the bar where the alert is triggered, providing a visual cue on the chart.
Alert Notification:
When the alert condition is met, the script can trigger an alert through TradingView's alert system. The alert sends a message ("Time-based alert triggered!") to notify you that the specified time has been reached.
Set the alert message to your CrossTrade flatten command and every account goes flat at your cutoff time automatically:
key=your-secret-key;
command=flatteneverything;
account=PROP1234;
destination=tradovate;A cutoff that does not depend on a chart
A time-based alert has one weak point: it only fires if TradingView evaluates the indicator at that minute, and TradingView alerts can arrive late at busy times, including the top of the hour. For a hard prop firm cutoff, a rule that runs on CrossTrade's own servers is the safer primary, with the alert as a backup.
The Account Manager gives each account a scheduled flatten time in US/Eastern. At that time it cancels working orders and closes positions, then checks the account really is flat. On Tradovate it runs entirely in the cloud with your computer off. On NinjaTrader it needs the NT8 Add-On running. Pair it with a trading window that stops new entries a few minutes earlier, and nothing can open a trade after your cutoff either.
Set the time before your firm's cutoff, not at it. On early-close and holiday sessions, check the exchange schedule and move the time earlier yourself, because the scheduled time does not move on its own.
Frequently asked questions
Can a TradingView alert fire at a specific time of day?
Yes. A time-based indicator can trigger an alert when the chart reaches a set hour and minute, and that alert can carry any webhook message.
How do I flatten all positions at a set time with TradingView?
Put the alert on a time-based indicator and set its message to a CrossTrade flatten command. The command closes every position and cancels working orders.
Is a time-based alert reliable enough for a prop firm cutoff?
Use it as a backup. TradingView alerts can be delayed at busy times, so a server-side scheduled flatten in the Account Manager is the safer primary.
Does the scheduled flatten work on Tradovate?
Yes. On Tradovate it runs on CrossTrade's servers with nothing on your computer. It is eligible for five minutes after the set time and does not flatten later if that window is missed.
What time zone does the scheduled flatten use?
US/Eastern, in 24-hour format. Set 15:50 for 3:50 PM Eastern.

