fbpx
Tickerly Trading bot service logo

BLOG

TradingView Bar Close Alerts: Set Up Once Per Bar Close

by

To get a TradingView alert that fires only when a candle has closed, open the alert dialog and set the trigger to Once Per Bar Close. In Pine Script, use alert() with alert.freq_once_per_bar_close. Either way, the alert waits for the bar to finish, so a condition that appears and vanishes mid-candle never reaches you. If the alert feeds an automated trading bot, the same setting decides which signals become orders. That makes it one of the most important choices in your automation. Tickerly turns those TradingView alerts into live orders on your connected exchange, so the rule you set on the chart is the rule your bot follows.

Tickerly
tickerly.net
Turn Confirmed Alerts Into Orders
Connect confirmed TradingView bar-close alerts to Tickerly and send them as live orders on your connected exchange.

Try for free

Key Takeaways

  • Once Per Bar Close is a trigger frequency in the alert dialog. It behaves like “Once Per Bar”, except the bar must close before the alert fires.
  • In Pine Script, alert.freq_once_per_bar_close limits an alert() call to the realtime closing update of a bar. barstate.isconfirmed is another way to gate the call.
  • Strategies normally recalculate at bar close, while indicators recalculate on every realtime update. The two need different handling.
  • A bar-close alert arrives after the close because TradingView must process the closing update and send the webhook. The receiving system should answer within three seconds.
  • Tickerly connects these alerts to your exchange, so a confirmed bar close becomes an order without code or a VPS.

Table of Contents

What “bar close” means for an alert

A bar (candle) on your chart is a time window: one minute, one hour, one day. While the window is open, the high, low and close keep changing. A condition such as “RSI crosses above 30” can be true at 10:42, false at 10:50 and true again at 10:58. Only the value at the final tick of the window is permanent.

That is the whole reason bar-close alerts exist. An alert that fires the moment a condition becomes true on a live bar can signal an entry that disappears before the candle ends. An alert that waits for the close signals only what the finished candle actually showed. For a trader who backtests on closed candles, this is usually the behavior that matches the strategy’s logic.

Live-bar and confirmed-close alert comparison

The trade-off is timing. You never get the first moment a condition was met, only the confirmation. That is deliberate, and it is why the execution step after the alert needs to be fast.

The four alert frequencies compared

TradingView’s guide to alert frequencies describes the options in the trigger dropdown. Here they are side by side:

Frequency When it triggers Typical use
Only Once Once, the first time the condition is met, then the alert stops One-off price levels
Once Per Bar When the condition is met, no more than once per bar Intrabar signals where speed matters more than confirmation
Once Per Bar Close Same as Once Per Bar, but the bar must close first Candle-confirmed entries and exits
Once Per Minute / Every Time The condition is checked every minute and triggers whenever it is met Monitoring fast-moving conditions

The difference between the second and third rows is the one that matters here. Once Per Bar can fire in the middle of a candle. Once Per Bar Close cannot.

How to set up a bar-close alert in the TradingView dialog

The alert dialog covers the symbol, condition, trigger frequency, expiration and message, as laid out in TradingView’s alert configuration guide. A bar-close alert takes these steps:

  1. Open the dialog. Press Alt+A on the chart, or click the alert button in the toolbar.
  2. Choose the condition. You can select an indicator, a strategy, a drawing tool or a price. The condition can also use an interval different from the chart’s interval.
  3. Set the trigger to Once Per Bar Close. For a price-crossing condition, this means the alert fires only if the candle closes beyond your level, not if a wick pokes through it.
  4. Set the expiration. Alerts expire, so pick a date that suits how long the strategy will run.
  5. Write the message. For a manual notification, any text works. For automation, the message must follow the format of the receiving system.
  6. Create the alert.

Two details cause most confusion. First, an alert stores a snapshot of the script, its inputs, the chart symbol and the timeframe when you create it. According to the Pine Script alerts documentation, later changes do not modify a running alert, so you recreate it to apply them. Second, TradingView alerts run on its servers around the clock and do not need you to stay logged in, per the same page.

If you want to understand the wider habit of timing alerts against how you act on them, this piece on trade alert timing is a good companion.

Bar-close alerts in Pine Script

If you write your own scripts, you control the frequency in code. Pine Script’s alert() function takes a frequency argument. According to the Pine Script documentation:

  • alert.freq_once_per_bar is the default. It allows only the first alert call on a realtime bar.
  • alert.freq_all allows every executed call during that bar.
  • alert.freq_once_per_bar_close makes a call eligible only on the realtime closing update of the bar.

A minimal example looks like this:

//@version=6
indicator("Bar close cross", overlay = true)
longCond = ta.crossover(close, ta.sma(close, 50))
if longCond
    alert("long", alert.freq_once_per_bar_close)

You can also gate the call with barstate.isconfirmed, which is true only on the last update of a bar. The documentation notes that the call must still execute on that update for the alert to trigger. A condition that was true earlier in the bar but is false at the close will not fire.

This matters for repainting. An indicator that evaluates a condition on every realtime tick can show a signal that later disappears. Tying the alert to the confirmed bar keeps the alert in line with what the finished chart shows. For a deeper look at designing scripts so signals do not change after the fact, see our guide on a multi-symbol TradingView strategy that avoids repainting.

Indicators and strategies behave differently

The frequency options apply to both indicators and strategies, but their execution schedules differ. According to the Pine Script alerts documentation, indicators recalculate on realtime updates, while strategies normally recalculate at bar close unless calc_on_every_tick is enabled.

What that means in practice:

  • Indicators need an explicit bar-close frequency, either in the dialog or in the alert() call. Without it, the default can fire on the first update of a bar.
  • Strategies already evaluate at bar close by default, so order-fill alerts usually line up with closed candles. If you turn on calc_on_every_tick, the strategy can generate orders intrabar, and you should expect alerts to follow.
  • Strategy alert events can be configured for order fills, alert calls, or both. Pick the one your receiving system expects, and avoid enabling both unless you need both messages.

One more point for strategy authors: position sizing, stops and other risk rules belong in the TradingView strategy itself. The alert then carries the resulting order to your bot.

Why the alert arrives after the candle seems to close

Traders often ask why a bar-close alert shows up a moment after the candle changes color. The alert triggers only once TradingView processes the realtime closing update and the alert call executes. If a webhook is configured, TradingView then sends it to the external URL. Each stage takes time.

The webhook documentation adds practical limits:

  • Two-factor authentication is required to use webhooks.
  • Ports 80 and 443 are accepted, and IPv6 is not supported.
  • If the receiving server takes more than three seconds to process the request, TradingView cancels it.
  • Webhook delivery can occasionally fail.

The three-second limit is why the receiving end matters so much. A receiver that does slow work before answering risks a cancelled request, and with a bar-close strategy you get one chance per candle. If alerts seem to go missing, our guide on missing TradingView alerts walks through the usual causes. For crypto-specific alerting habits, crypto price alerts covers how traders tune thresholds.

Sending bar-close alerts to an automated trading bot

A bar-close alert is most valuable when the signal turns into an order with no manual step. The route is simple: TradingView fires the alert on the confirmed close, the webhook carries the message, and the receiver places the order on your exchange. The webhook field holds the receiver’s URL, and the message must be formatted to match what the receiver expects. Valid JSON is sent as application/json, per TradingView’s webhook guide.

Here is how that looks with Tickerly:

  1. Connect your exchange. Our exchange setup page shows how to link your account through its API, and the list of supported exchanges shows what you can connect.
  2. Build your alert message. The alert message structure page shows the format. Use that format exactly, so you add no fields of your own.
  3. Create the alert in TradingView. Choose your strategy or indicator, set the frequency to Once Per Bar Close, and paste the message.
  4. Test on a demo account. Testing runs on the exchange’s demo account, so you can watch a few closed candles produce orders before you use real funds.
  5. Go live. Tickerly converts each alert into an order within a fraction of a second of receiving it, with no code and no VPS required.

The important thing is how this fits your strategy: the bar-close rule sits in TradingView, and Tickerly handles the path from alert to order. You can manage multiple strategies and alerts at once, across crypto, forex, stocks and futures. Our walkthrough on how to automate trading on TradingView using Tickerly covers the full setup, and TradingView alerts to exchange explains routing in more detail.

Check what happened after each close

When a bar-close alert fires but you do not see the order you expected, start with the alert itself: was the condition true on the final update of the bar? Then check the alert’s expiration and whether you recreated it after editing the script. The alert log shows what reached Tickerly, which helps you separate a TradingView-side question from an exchange-side one.

Common mistakes with bar-close alerts

  • Editing the script and expecting the alert to update. The alert keeps the snapshot from creation. Delete it and create a new one.
  • Mixing frequencies. An indicator alert left on Once Per Bar while the strategy logic assumes closed candles produces entries the backtest never showed.
  • Forgetting the interval. The condition can use a different interval from the chart. Confirm that the alert’s interval is the timeframe your strategy was designed for.
  • Letting alerts expire. An expired alert simply stops. Note expiration dates for every automated alert.
  • Hitting plan limits. More strategies and symbols mean more alerts. Our post on TradingView alert limits shows how to get more usable alerts from the ones you have.
  • Treating the close as the entry price. Orders execute after the close is processed, so the fill can differ from the closing price. Plan your strategy around that.

Choosing a plan for bar-close automation

Bar-close strategies tend to need few alerts per symbol, which makes them an efficient fit for automation. Tickerly starts with a 30-day free trial. After that, plans are Level 2 at $19 per month, Level 3 at $29 per month and Level 4 at $39 per month, with a higher Level 4 Ultra tier for larger setups. The plans page lists what each tier supports in asset classes, strategies and alerts.

Tickerly

If your strategy already generates a Once Per Bar Close alert, you can start with Tickerly and connect it to your exchange in a single session.

Our perspective

Most of the questions we see about bar-close alerts are really questions about trust. A trader wants the bot to do what the strategy does on a closed candle, every time, without watching the screen.

That is why we think the frequency setting deserves more attention than it gets. It is the line between a signal and noise. Set it once, recreate the alert when the script changes, and the rule lives in TradingView, where your strategy lives.

What we build is the part after the alert: a no-code connection from TradingView to your exchange, with execution within a fraction of a second, no VPS and support for as many strategies as your plan allows. The decision stays with your strategy. The order placement is ours.

If you automate more than one strategy, give each one its own clear alert and message, and keep bar-close logic consistent across them. It makes troubleshooting far simpler.

Jay

FAQ

Is “Once Per Bar Close” the same as “Once Per Bar”?

No. Both limit the alert to one trigger per bar, but Once Per Bar can fire as soon as the condition is met during the candle. Once Per Bar Close waits until the bar has closed, as described in TradingView’s alert frequency guide.

How do I make a Pine Script alert fire only after a bar is confirmed?

Use alert() with alert.freq_once_per_bar_close, which makes the call eligible only on the realtime closing update. You can also gate the call with barstate.isconfirmed. The call still has to execute on that update for the alert to trigger.

Do bar-close alerts work the same for strategies and indicators?

The frequency options apply to both, but the schedules differ. Indicators recalculate on realtime updates, while strategies normally recalculate at bar close unless calc_on_every_tick is enabled. Strategy alerts can also be set for order fills, alert calls, or both.

Why did my alert not change after I edited my script?

An alert stores a snapshot of the script, inputs, symbol and timeframe when you create it. Later edits do not change a running alert, so delete it and create a new one to apply your changes.

Can I send a bar-close alert straight to my exchange?

Yes. Put the receiving system’s URL in the alert’s webhook field and format the message to match it. With Tickerly, you connect your exchange through its API and paste the message in the supported format. The alert then becomes an order, and you can start with the 30-day free trial.

Sources

This article was produced with Al assistance and reviewed for accuracy. It is provided for general information only and is not professional or financial advice.

Tags :

Latest Post