OPEN-SOURCE SCRIPT
Zaktualizowano Execution-Aware Trend [BSL]

Execution-Aware Trend is a deliberately ordinary trend-and-breakout strategy
whose main product is visible testing discipline. It answers “what did this
exact ruleset simulate after declared costs, next-tick execution and a fixed
sample split?” It does not predict the next move and does not claim an edge.
This is an original BarState Labs implementation created from an independent
written specification. It does not reproduce another publication’s source,
defaults, interface, chart grammar or report.
HOW IT WORKS
Trend qualification uses a fast and slow EMA. A long setup requires the fast
EMA above the slow EMA and the slow EMA above its value at the configured slope
lookback. The short rule is symmetric. Equality qualifies neither side.
Entry and exit channels always exclude the current bar:
`entryHigh = highest(high[1], entry length)`
`entryLow = lowest(low[1], entry length)`
`exitHigh = highest(high[1], exit length)`
`exitLow = lowest(low[1], exit length)`
A confirmed close beyond the prior entry channel creates a market-entry
intent only when the matching trend filter qualifies. There is no pyramiding
and no same-calculation reversal.
The close-risk line uses ATR and confirmed closes. For a long position, the
highest observed close is tracked and the line is the greater of its previous
value and `peak close - ATR multiple × ATR`. It therefore never loosens. The
short rule is symmetric and never rises. A channel breach or a confirmed close
through the risk line creates a market-close intent.
EXECUTION MODEL AND COSTS
Orders are not processed on the signal bar’s close. The strategy keeps
TradingView’s normal next-tick behavior, which on historical bars normally
means a fill at the following bar’s open. The declaration includes:
- 0.10% commission per filled order;
- 2 ticks of slippage per market fill;
- 10% of equity order size;
- no pyramiding and no simulated leverage;
- no calculation on every tick or on order fills.
These are generic examples, not estimates for a particular broker or market.
Users must replace them in Properties. The panel cannot detect a manual
Properties override, so it labels them declaration defaults. Simulated fills
do not model liquidity, spread variation, queue position, rejected orders or
market impact.
SAMPLE WINDOWS
The same signal parameters can be viewed as Full history, In-sample or
Out-of-sample. The default split is 2024-01-01 UTC. In-sample ends immediately
before the split; out-of-sample begins at the split. No entry is allowed
outside the selected window, and an open position is closed by a normal delayed
market intent when the window ends.
One visible split does not prove that a user avoided tuning after seeing the
result. The script exposes the boundary; it cannot enforce research behavior.
A visible 100-closed-trade gate is a sample-size warning, not statistical
proof.
CONFIRMED AND STANDARD-CHART BOUNDARIES
New orders require a confirmed bar and `chart.is_standard`. On Heikin Ashi,
Renko, Kagi, Line Break, Range, Point & Figure and other non-standard charts,
the script displays `NON-STANDARD — NO ORDERS` and creates no trades.
The script uses only the current chart symbol and timeframe. It makes no
external requests, uses no lookahead and does not force same-bar-close fills.
Exchange or broker feed corrections can still rebuild historical standard
OHLC after reload.
OUTPUTS
The chart shows fast and slow EMAs, optional prior-bar entry and exit channels,
the active close-risk line, optional sample background and confirmed intent
markers. Compact and Full panels expose state, sample, split, fill model,
declaration costs, closed trades, the 100-trade gate, net result, average closed
trade and maximum drawdown.
Hidden machine-readable plots expose:
- Confirmed entry intent: +1, -1 or 0;
- Confirmed exit intent: +1, -1 or 0;
- Selected sample: 1 or 0;
- OOS flag: 1 or 0.
Order calls contain explicit alert messages, so TradingView order-fill alerts
can identify the simulated action, size, ticker and resulting strategy
position. They are diagnostics, not recommendations.
LIMITATIONS
- Positive net profit is not a design requirement or evidence of robustness.
- Results depend on symbol, feed, timeframe, loaded history, Properties and
inputs.
- Close-confirmed risk exits can gap on the next simulated fill.
- Commission and slippage defaults are not a complete transaction-cost model.
- One in-sample/out-of-sample split is not walk-forward validation.
- The 100-trade gate does not establish significance or future performance.
- Backtests are simulations and are not trading advice or expected returns.
VALIDATION
The candidate passed 16 deterministic Python fixtures and a 16/16 live Pine
harness. Manual TradingView checks covered BTCUSDT and AAPL on daily and
intraday charts, 187 BTCUSDT 30-minute and 103 AAPL hourly trades, unchanged
parameters across IS/OOS, higher costs, reload parity, realtime confirmation,
daily Bar Replay, zero orders on Heikin Ashi, the order-fill alert dialog,
390 × 844 rendering and Pine Profiler. The profiler observed 32,614 executions
on DJI daily history with 0.6 seconds total runtime.
The validation intentionally retains unfavorable evidence: BTCUSDT 30-minute
Full history returned about -3.70%, AAPL hourly Full history about -2.63%, and
AAPL daily OOS about -1.83%. No parameter was retuned after these observations.
ORIGINALITY AND SOURCE
Category demand was selected from dated popularity metadata. No protected,
invite-only or closed source was accessed, and no compared script’s source was
imported. EMA, ATR, prior-bar channels and sample splitting are standard,
transparent building blocks. The implementation is released under MPL 2.0.
CHANGELOG
v1.0.0
- Initial open-source release candidate.
- Symmetric confirmed-close trend and prior-channel entries.
- Non-loosening ATR close-risk line with delayed market exits.
- Explicit commission, slippage, sample split and standard-chart guard.
- Compact/Full evidence panels, signed intent exports and order-fill messages.
whose main product is visible testing discipline. It answers “what did this
exact ruleset simulate after declared costs, next-tick execution and a fixed
sample split?” It does not predict the next move and does not claim an edge.
This is an original BarState Labs implementation created from an independent
written specification. It does not reproduce another publication’s source,
defaults, interface, chart grammar or report.
HOW IT WORKS
Trend qualification uses a fast and slow EMA. A long setup requires the fast
EMA above the slow EMA and the slow EMA above its value at the configured slope
lookback. The short rule is symmetric. Equality qualifies neither side.
Entry and exit channels always exclude the current bar:
`entryHigh = highest(high[1], entry length)`
`entryLow = lowest(low[1], entry length)`
`exitHigh = highest(high[1], exit length)`
`exitLow = lowest(low[1], exit length)`
A confirmed close beyond the prior entry channel creates a market-entry
intent only when the matching trend filter qualifies. There is no pyramiding
and no same-calculation reversal.
The close-risk line uses ATR and confirmed closes. For a long position, the
highest observed close is tracked and the line is the greater of its previous
value and `peak close - ATR multiple × ATR`. It therefore never loosens. The
short rule is symmetric and never rises. A channel breach or a confirmed close
through the risk line creates a market-close intent.
EXECUTION MODEL AND COSTS
Orders are not processed on the signal bar’s close. The strategy keeps
TradingView’s normal next-tick behavior, which on historical bars normally
means a fill at the following bar’s open. The declaration includes:
- 0.10% commission per filled order;
- 2 ticks of slippage per market fill;
- 10% of equity order size;
- no pyramiding and no simulated leverage;
- no calculation on every tick or on order fills.
These are generic examples, not estimates for a particular broker or market.
Users must replace them in Properties. The panel cannot detect a manual
Properties override, so it labels them declaration defaults. Simulated fills
do not model liquidity, spread variation, queue position, rejected orders or
market impact.
SAMPLE WINDOWS
The same signal parameters can be viewed as Full history, In-sample or
Out-of-sample. The default split is 2024-01-01 UTC. In-sample ends immediately
before the split; out-of-sample begins at the split. No entry is allowed
outside the selected window, and an open position is closed by a normal delayed
market intent when the window ends.
One visible split does not prove that a user avoided tuning after seeing the
result. The script exposes the boundary; it cannot enforce research behavior.
A visible 100-closed-trade gate is a sample-size warning, not statistical
proof.
CONFIRMED AND STANDARD-CHART BOUNDARIES
New orders require a confirmed bar and `chart.is_standard`. On Heikin Ashi,
Renko, Kagi, Line Break, Range, Point & Figure and other non-standard charts,
the script displays `NON-STANDARD — NO ORDERS` and creates no trades.
The script uses only the current chart symbol and timeframe. It makes no
external requests, uses no lookahead and does not force same-bar-close fills.
Exchange or broker feed corrections can still rebuild historical standard
OHLC after reload.
OUTPUTS
The chart shows fast and slow EMAs, optional prior-bar entry and exit channels,
the active close-risk line, optional sample background and confirmed intent
markers. Compact and Full panels expose state, sample, split, fill model,
declaration costs, closed trades, the 100-trade gate, net result, average closed
trade and maximum drawdown.
Hidden machine-readable plots expose:
- Confirmed entry intent: +1, -1 or 0;
- Confirmed exit intent: +1, -1 or 0;
- Selected sample: 1 or 0;
- OOS flag: 1 or 0.
Order calls contain explicit alert messages, so TradingView order-fill alerts
can identify the simulated action, size, ticker and resulting strategy
position. They are diagnostics, not recommendations.
LIMITATIONS
- Positive net profit is not a design requirement or evidence of robustness.
- Results depend on symbol, feed, timeframe, loaded history, Properties and
inputs.
- Close-confirmed risk exits can gap on the next simulated fill.
- Commission and slippage defaults are not a complete transaction-cost model.
- One in-sample/out-of-sample split is not walk-forward validation.
- The 100-trade gate does not establish significance or future performance.
- Backtests are simulations and are not trading advice or expected returns.
VALIDATION
The candidate passed 16 deterministic Python fixtures and a 16/16 live Pine
harness. Manual TradingView checks covered BTCUSDT and AAPL on daily and
intraday charts, 187 BTCUSDT 30-minute and 103 AAPL hourly trades, unchanged
parameters across IS/OOS, higher costs, reload parity, realtime confirmation,
daily Bar Replay, zero orders on Heikin Ashi, the order-fill alert dialog,
390 × 844 rendering and Pine Profiler. The profiler observed 32,614 executions
on DJI daily history with 0.6 seconds total runtime.
The validation intentionally retains unfavorable evidence: BTCUSDT 30-minute
Full history returned about -3.70%, AAPL hourly Full history about -2.63%, and
AAPL daily OOS about -1.83%. No parameter was retuned after these observations.
ORIGINALITY AND SOURCE
Category demand was selected from dated popularity metadata. No protected,
invite-only or closed source was accessed, and no compared script’s source was
imported. EMA, ATR, prior-bar channels and sample splitting are standard,
transparent building blocks. The implementation is released under MPL 2.0.
CHANGELOG
v1.0.0
- Initial open-source release candidate.
- Symmetric confirmed-close trend and prior-channel entries.
- Non-loosening ATR close-risk line with delayed market exits.
- Explicit commission, slippage, sample split and standard-chart guard.
- Compact/Full evidence panels, signed intent exports and order-fill messages.
Informacje o Wersji
v1.0.1- Fixed the Compact panel on live 24/7 markets. With calc_on_every_tick=false, the strategy now initializes its evidence table on the last confirmed historical bar, so the panel remains visible while the realtime bar is open.
- Trading logic, entries, exits, declared costs, sample window and defaults are unchanged.
Informacje o Wersji
Readability update. The evidence panel can now choose Auto, Top right, or Bottom right; Auto positions it opposite the latest price within the visible range. Order comments are shortened to compact audit codes so TradingView's required strategy trade markers remain legible. Entry, exit, risk, cost, and sizing logic are unchanged.Informacje o Wersji
This update opens in Full history so a new chart starts with a larger descriptive sample. The compact panel now fills all ten rows, and lighter channel shading keeps price readable. Costs remain non-zero and orders still fill on the next bar. The strategy logic is unchanged. Switch to Out-of-sample when you want a dated split.Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.
Skrypt open-source
W zgodzie z duchem TradingView twórca tego skryptu udostępnił go jako open-source, aby użytkownicy mogli przejrzeć i zweryfikować jego działanie. Ukłony dla autora. Korzystanie jest bezpłatne, jednak ponowna publikacja kodu podlega naszym Zasadom serwisu.
Wyłączenie odpowiedzialności
Informacje i publikacje nie stanowią i nie powinny być traktowane jako porady finansowe, inwestycyjne, tradingowe ani jakiekolwiek inne rekomendacje dostarczane lub zatwierdzone przez TradingView. Więcej informacji znajduje się w Warunkach użytkowania.