TradingView strategy research

End-of-day trading strategy: signal close vs auction fill

An end-of-day trading strategy makes decisions from daily price information. If the rule requires the final closing price, that signal becomes known after the closing auction has determined its price. Use the next available trading session for execution unless a separately specified rule can submit an eligible auction order before its deadline. A simulated fill at the signal close does not prove that a live order could obtain that price.

See the decision guide

Three execution models with different information

Record the observation time, order-submission deadline and fill assumption separately. In a daily historical chart, seeing a closing price does not establish that the price was available early enough to submit an order for that auction. The following distinctions apply to both entries and exits.

  • TradingView documents next-tick fills by default. With calculation at bar close, a daily market order normally fills at the next daily open. The chart feed and session definition determine what that open represents.
  • Setting process_orders_on_close to true permits same-tick simulated fills. TradingView warns that alerts sent after a closed session may only lead to real execution when the market opens again.
  • A Pine strategy order is a simulated order. An external broker connection needs its own order type, routing, deadline and acknowledgment checks; a chart marker is not an exchange acceptance record.
ModelInformation usedExecution assumption
Confirmed daily signalFinal daily close, high, low and completed indicators.Submit after confirmation; the baseline simulates a market fill at the following daily open, with slippage.
Pre-close auction decisionA frozen snapshot before the applicable cutoff, plus earlier completed sessions.Submit an eligible MOC or LOC order in time. The auction price is unknown when the order is submitted; a limit can prevent execution.
Same-close simulator fillFinal close used to create the order.The emulator fills on the closing tick when configured to do so. Treat this as a timing sensitivity case until a real submission path is established.

What a pre-close order can actually know

NYSE states that ordinary MOC and LOC entry ends at 15:50 Eastern Time, with an exception for orders offsetting a significant imbalance. The normal closing auction is at 16:00. These are venue rules, not a universal deadline: a broker can require an earlier submission, and special sessions need their own schedule. Confirm the current rules for the exact venue and order route.

  • A separate research variant could freeze the completed 15:45 five-minute bar on a normal NYSE session and compare its close with the highest high of the previous 20 completed daily sessions. Submit only if the broker can accept and route the order before its cutoff. The five-minute snapshot is available earlier than the final daily candle.
  • Suppose the prior daily threshold is $99.50. A 15:45 snapshot of $99.40 fails the pre-close rule even if the final close reaches $100.00. A snapshot of $99.60 passes even if the final close later falls to $99.30. Those are different signals, not fill-price adjustments to one signal.
  • Do not backfill the 15:45 decision with the final daily high, volume or close. Keep the snapshot timestamp and broker acknowledgment. An order that misses the cutoff is a rejected or missed auction attempt, not a trade at the historical closing price.
  • This page implements the confirmed daily version below. Testing the auction variant needs intraday snapshots and auction execution records; daily OHLC alone cannot reconstruct order eligibility or queue outcomes.

A fixed daily breakout baseline

Use one US cash-equity symbol on standard 1D candles, with its daily session and adjustment settings recorded. The example is long-only, uses 10 shares, starts with $100,000 and has no leverage or pyramiding. The defaults are research choices, not an established profitable strategy.

  • If the entry fills at the session t + 1 open and the SMA exit never triggers, the fifth holding session ends at t + 5 close. Submit the time exit then; its fill is at t + 6 open. Holidays and weekends do not count as holding sessions.
  • An entry close equal to the prior high does not qualify. A holding close equal to its SMA does not trigger the price exit, but the maximum-session exit can still apply.
  • This system carries overnight exposure. A close-based exit provides no intraday loss ceiling, and a gap can make the next opening fill much worse. Position size and a different protective-order policy require separate research.
DecisionExact baseline rule
Entry signalWhile flat, require a completed daily close strictly above the highest high of the previous 20 completed daily bars. Exclude the current high. Wait for all 20 prior bars and the exit average to be available.
Entry orderSubmit a market buy after the signal close. Simulate its fill at the next available daily open plus adverse slippage. Do not cancel it using a gap that becomes known only at that open.
Exit decisionAt each completed holding session, exit if the close is strictly below its 10-day SMA, including that close, or if five holding sessions have completed. Count the session of the entry fill as session one.
Exit orderSubmit a market exit after the decision close. Simulate the fill at the next daily open minus adverse slippage. Ignore entry signals while holding; later signals may open a new trade once flat.
Costs and riskCharge 0.05% of filled notional on each side and two minimum ticks of slippage per market fill. There is no intraday protective stop or profit target in this daily-only baseline.

A gap and cost example you can reproduce

Assume a $100 signal close above a $99.50 prior-high threshold. The next session opens at $102, and a later exit fills around a $103 opening reference. Hold that exit reference fixed to isolate entry timing. For 10 shares, an assumed $100 closing entry produces $30 gross, while the executable-timing model using $102 produces $10 gross before costs. The missing $20 is the entry gap, not commission.

  • The baseline does not know the next open when it decides to buy. A rule that skips gaps above a threshold needs observation and order placement at or after the open, with a later executable fill assumption.
  • At zero price movement between reference entry and exit, two-sided slippage and commission still create a loss. The two-tick assumption here is illustrative; it does not reproduce changing spreads, auction impact or broker minimum charges.
  • A same-close setting can change both entry and exit timing. The $30 versus $10 comparison holds the exit fixed for arithmetic only; it is not the result of running two TradingView backtests.
StepHypothetical calculation
Tick size and slippage$0.01 tick × 2 ticks = $0.02 adverse movement per fill.
Entry and exit fillsBuy 10 at $102.02; sell 10 at $102.98.
Gross P&L after slippage10 × ($102.98 - $102.02) = $9.60.
Two-sided commission0.0005 × 10 × ($102.02 + $102.98) = $1.025.
Net P&L$9.60 - $1.025 = $8.575, or $8.58 rounded to cents.
Larger adverse entry gapIf the entry reference is $104 instead, fills $104.02 and $102.98 yield -$10.40 gross, $1.035 commission and -$11.435 net.

Complete Pine Script with next-session execution

Paste this Pine Script v6 strategy into TradingView and use standard 1D equity candles. Blue Signal markers show the decision bars; strategy fill markers should occur on later bars. The code explicitly disables same-close fills and intrabar recalculation. Keep those properties unchanged when checking the baseline.

  • The script rejects intraday, weekly, multi-day and synthetic charts. It uses the supplied daily bars rather than a hard-coded 16:00 clock. Verify that the feed represents the intended equity daily session; the script does not validate the exchange calendar or auction price source.
  • The last available signal can remain unfilled if there is no following bar. An open trade at the end of the sample stays open; do not silently count its marked value as a completed trade.
  • There is no request.security call or future daily lookup. The entry threshold uses high[1] across the prior lookback. The current close enters the exit SMA only after that bar has completed.
Illustrative long-only daily strategy. Two ticks use the selected symbol minimum tick; only the worked example assumes $0.01. Syntax validation is not a live execution or performance test.pine
//@version=6
strategy("EOD breakout: next-session execution", overlay = true, initial_capital = 100000, currency = currency.USD, default_qty_type = strategy.fixed, default_qty_value = 10, pyramiding = 0, margin_long = 100, commission_type = strategy.commission.percent, commission_value = 0.05, slippage = 2, process_orders_on_close = false, calc_on_every_tick = false, calc_on_order_fills = false)
int breakoutLength = input.int(20, "Prior high lookback", minval = 2)
int exitLength = input.int(10, "Exit SMA length", minval = 2)
int holdingSessions = input.int(5, "Maximum completed holding sessions", minval = 1)
if not chart.is_standard or not timeframe.isdaily or timeframe.multiplier != 1
    runtime.error("Use standard 1D candles and verify the equity daily session.")
float priorHigh = ta.highest(high[1], breakoutLength)
float exitAverage = ta.sma(close, exitLength)
bool ready = bar_index >= breakoutLength and not na(exitAverage)
bool entrySignal = barstate.isconfirmed and ready and strategy.position_size == 0 and close > priorHigh
bool exitSignal = false
if barstate.isconfirmed and ready
    if strategy.position_size > 0
        int completedSessions = bar_index - strategy.opentrades.entry_bar_index(0) + 1
        exitSignal := close < exitAverage or completedSessions >= holdingSessions
        if exitSignal
            strategy.close("Long", comment = "Daily exit; next open")
    else if entrySignal
        strategy.entry("Long", strategy.long, comment = "Confirmed breakout; next open")
plot(priorHigh, title = "Previous sessions' highest high", color = color.blue)
plot(exitAverage, title = "Daily exit SMA", color = color.orange)
plotshape(entrySignal, title = "Entry decision at close", style = shape.triangleup, location = location.belowbar, color = color.blue, text = "Signal")
plotshape(exitSignal, title = "Exit decision at close", style = shape.triangledown, location = location.abovebar, color = color.orange, text = "Exit")

Calendar boundaries that change the experiment

Define the exchange session before interpreting daily bars. NYSE lists a normal core session of 09:30 to 16:00 Eastern Time and scheduled 13:00 equity closes on certain holidays. The daily baseline follows actual chart bars; a timed intraday or auction implementation must explicitly handle special sessions.

BoundaryRequired check
DST and display timezoneUse America/New_York for US equity clock rules, not a fixed UTC-5 offset. Changing the chart display timezone does not change Pine calendar calculations.
Holiday or weekendNext session means the next available tradable session, not tomorrow or a fixed 24-hour timestamp. A Friday signal can wait until Tuesday after a Monday closure.
Short sessionA fixed 15:45 snapshot does not exist before a 13:00 close. Skip that auction variant unless its earlier snapshot and broker cutoff have been specified in advance. The daily baseline can still process the completed short-session daily bar.
Halt or missing barA delayed reopening or missing feed bar changes when a next-bar fill appears. Audit those trades against the market calendar and data source; the emulator does not prove an opening fill was attainable.
Other marketsFutures session dates and settlement prices, FX daily rollovers and 24-hour crypto boundaries need their own definitions. They are outside this cash-equity example.

Audit timing before searching parameters

Save the symbol, exchange, timeframe, session, adjustment mode, date range and strategy properties with each run. Inspect individual entry and exit timestamps before comparing a summary metric. A profitable report under an impossible timing assumption does not validate the strategy.

  • Check an equal-threshold non-signal, the first eligible bar after warm-up, a gap entry, an early SMA exit and the fifth-session exit. Inspect a holiday, a short session and the final unfilled signal separately.
  • Keep the confirmed-close/next-open baseline separate from a pre-cutoff auction system. The latter needs different observations, missed-order counts and fill evidence, so a higher result cannot be attributed only to execution price.
  • Choose a small parameter grid on development dates, then freeze it for later untouched dates. Report net P&L, average net trade, drawdown, trade count and overnight-gap exposure together. Repeat costs at a predeclared higher level.
  • Ask Pine Script AI Coding Agent to adapt the written rules and explain its generated source. Strategy Optimizer can compare exposed inputs through its TradingView extension. Neither tool establishes that a broker accepted an auction order or that historical returns will repeat.
Where Pineify fits

Pine Script AI Coding Agent

Draft changes to the daily rules, then review the resulting Pine source and confirm each signal and fill timestamp against the specification.

Also useful: Strategy Optimizer. Compare exposed lookback and holding-period inputs after validating order timing. Keep a later evaluation period outside parameter selection.

Draft the daily strategy

Frequently asked questions

Educational research, not investment advice. Rules and prices are illustrative, with no live or historical performance claim. Daily exits leave overnight and intraday risk; losses can exceed an expected price move. Syntax checks do not validate execution feasibility or future returns.

Sources and verification

Published by Pineify. Pineify is an independent product and is not affiliated with TradingView. Sources support the technical explanations; examples do not establish trading performance.