OPEN-SOURCE SCRIPT
Aggiornato

Atty Strategy Seeker

186
Searches up to 1,536 simple strategies on your chart, ranks them, and then spends most of its panel explaining why the winner probably means nothing. That second half is the point of the tool.

Every strategy search has the same three problems. This one answers all three on screen instead of leaving them invisible.

1. FILLS
A backtest that fills a stop AT the stop deletes its own left tail. Here a stop pays the WORSE of the level and the bar open, stop exits pay extra slippage on top of the normal amount, and the panel prints how many stop exits gapped straight through the level and how many ticks worse they actually filled. It also prints how many exits hit stop and target on the same bar, which is a question the bar data cannot settle. Those are resolved as the stop by default, and you can flip it to see how much of the result rests on that assumption.

2. TIMING
A signal computed from a bar close is not knowable until that close prints, so entries fill at the NEXT bar open by default. Trailing stops test the level carried in from the previous bar BEFORE ratcheting on this bar close. Doing it the other way around lets a stop that was lifted by the closing price be tested against a low that happened before that price existed, and it always flatters the result. Exit-on-reverse-signal is queued to the next open for the same reason. The optimistic settings are included deliberately so you can measure how much of any result is the assumption rather than the signal.

3. SELECTION
The best of N strategies is the maximum of N draws, not an estimate of anything. Four rows address this:

LUCK - what the best of N scores on pure noise. Computed from the Gumbel limit for the maximum of N standard normals: a typical best, and a 95th percentile ceiling, both shown against the champion's own t-stat.

NULL - how many of the N qualified, how many of those made money, the median t and the median net across the whole search. If a large share of a random search is profitable, a profitable champion is not evidence of anything.

HOLDOUT - the top K are frozen at a split point and then tracked with no re-ranking at all.

WALK-FORWARD - an equal-weight basket credited only from trades whose strategy was already ranked in before the trade existed, and credited from the strategy's own realised trade returns rather than a close-to-close proxy, so what is measured is what was ranked.

Everything in-sample is labelled FITTED, including the leaderboard and the champion curve. The drawn trades of the selected row carry an on-chart stamp saying they are on the chart because they won.

HONEST LIMITS
- The strategies are heavily correlated, since 24 entry signals are reused across exits and filters. The effective independent count is therefore below N and the true luck bar sits below the printed one. The test errs toward rejecting a real edge rather than passing a fake one.
- The t-stat treats trade returns as independent and identically distributed. Overlapping trades and fat tails both inflate it.
- A frozen holdout is one split, not a proper cross-validation, and it is still the same symbol and the same period.
- Positions open at the right edge are not in the statistics.

SETTINGS
24 entry signals, 8 exit rules, 6 market filters, long and short. Search sizes 288 / 768 / 1536. Rank by t-stat, profit factor, net, expectancy, return over drawdown, or win rate. Slippage and commission per side with a separate stop-slippage charge, ATR length and distance scaling, six themes, eight panel positions, and every layer individually toggleable.

All signals evaluate on chart data and every alert is gated on barstate.isconfirmed, so no alert here can fire and then un-fire.

This is a measurement tool. It makes no performance claim, it is not a signal service, and a result it likes is still in-sample. Read the WF and HOLDOUT rows before anything else on the panel.
Note di rilascio
v2 — more measurement, and one silent bug removed.

CONCEPT-FAMILY BASKET. The 24 entry signals are five ideas in 24 costumes, so they are now mapped to fixed families: RANGE, BREAKOUT, TREND, MOMENTUM, SHOCK. A new basket rule takes the best strategy in EACH family rather than the top K overall. On ES the old top ten was seven variants of one mean-reversion idea, so a top-five basket diversified nothing. Selection stays walk-forward: each family champion is re-chosen bar by bar and a trade only counts for the basket if its strategy already held the title before the trade existed.

DIVERSIFICATION IS MEASURED, NOT ASSUMED. A new row reports the average pairwise correlation of the five legs' bar-by-bar exposure, and a smoothing ratio: mean standalone leg drawdown divided by basket drawdown. Above 1.0 the basket is smoother than its average leg; below 1.0 the diversification cost you something. Worth knowing that legs measuring 0.00 correlation still produced a ratio below 1.0 in testing, because average correlation is not tail correlation.

AVERAGE HOLD TIME per strategy, in bars and in real time units. Whether a result is intraday is now readable instead of inferred.

FORCE FLAT AT A FIXED TIME each day, with timezone and clock inputs, and entries blocked from that time. Deliberately a clock and NOT the Pine session built-ins: on a futures symbol with a near-24-hour session those fire once a day at 17:00 even on a chart displaying regular hours only, so a force-flat built on them silently never triggers. That bug was caught here by the new hold-time column reporting 25-hour holds with force-flat supposedly on.

WORST SESSION row. Total return and maximum drawdown are not what fails a funded-account evaluation; a single day is. The panel now reports the basket's worst session, best session and session count.

DOLLAR MODE. The pane can be denominated from a starting balance, with each basket leg drawn as its own curve and the basket bold over them, against a buy-and-hold benchmark that defaults to the cash index rather than the chart symbol. A back-adjusted continuous futures series has correct price differences but distorted ratios, so a percent return taken off one is wrong.

Also fixed: champion hysteresis no longer inverts when the champion's score is negative.

Note on performance: at the largest search size on long windows this is close to the platform calculation limit. If it returns nothing, reduce the search size or the bar count.

Declinazione di responsabilità

Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.