Every strategy idea goes through the same grind. You write a first version, run the backtest, see too few trades or a drawdown you would never sit through, change one rule, run it again, and repeat until it is late and you can no longer remember which version did what. Worse, the version you finally like is often the one you tuned hardest to the exact bars you were looking at, which is the version least likely to mean anything on bars it has not seen. PineScripter's strategy builder automates the grind and builds the second problem into its rules. You describe the strategy and set goals, and an agent writes a Pine Script v6 version, simulates it, scores it against your goals on an earlier stretch of bars and a later one it does not tune on, and tries again from its best attempt. This post explains how it works in detail, and is just as specific about what a passing result does not mean.
Short answer
PineScripter's strategy builder, on the Ultra and Power plans, takes a strategy you describe in a sentence or two plus a market, timeframe, direction and a set of goals (for example at least 100 closed trades, a maximum drawdown of 30%, a profit factor of at least 1.3). Each goal has two thresholds: one for the earlier bars and one for a later stretch, 30% or 50% of the history, that the search does not tune on. A goal counts only when both pass. The builder writes a version in Pine Script v6, checks it, simulates it with your capital and costs, scores how close it came, and revises from the best attempt so far, for 30 minutes up to four hours or until up to five scripts pass. The closest script opens in the editor. It is a simulation of the past, not a forecast.
Key facts
- The strategy builder is on Ultra and Power. Every attempt uses credits, like any other AI request.
- You describe the rules in plain English. The builder writes each attempt as a Pine Script v6 strategy and checks that it compiles before simulating it.
- History is split in two. The later 30% or 50% of the bars is out of sample: the search is scored on it, but it is never the stretch the rules were shaped on.
- A goal counts only when it passes on both windows. The default goals are at least 100 closed trades, a win rate of at least 40%, a maximum drawdown of 30% (35% out of sample) and a profit factor of 1.3 (1.1 out of sample).
- Net profit, Sharpe, Sortino and CAGR can be added as goals, up to eight in total.
- Each attempt gets a score from 0 to 100: mostly the share of goals met on both windows, plus a smaller part for how far past or short of each threshold it landed.
- A search runs for 30 minutes, 1, 2 or 4 hours, makes at most 60 attempts, and stops early once the number of passing scripts you asked for (1 to 5) is reached.
| Setting | Default | What it controls |
|---|---|---|
| Market, timeframe, direction | Your choice; long and short | What the strategy is simulated on, and which side it may trade |
| Bars | 17,520 (two years of 1 hour bars) | How much history the search sees, from 200 to 20,000 bars |
| Out of sample | 30% (or 50%) | The later share of bars every goal must also pass on |
| Capital and position size | 10,000, 25% of equity, 1 entry | How each simulated trade is sized |
| Costs | 0.05% commission, 2 ticks slippage | What each simulated fill pays |
| Run for / stop after | 30 minutes / 1 passing script | When the search ends |
What you give it: a description, a market, and goals
The builder starts from your idea, not from a menu of presets. You describe the rules in a sentence or two, the way the panel's own example does: "go long when price closes above the 20-bar high, and exit when it closes back inside." You choose the market from the chart's crypto spot markets, the timeframe, the number of bars, and whether the strategy may go long, short or both. Then you set the simulation's money settings, starting capital, the share of equity per trade, how many entries may be open, commission and slippage, so every attempt is judged with costs in it rather than in a frictionless world.
The goals are what make it a search rather than a generator. Each goal is a metric with a threshold: closed trades at least some number, win rate at least some percentage, maximum drawdown at most some percentage, profit factor at least some ratio, and optionally net profit, Sharpe, Sortino or CAGR. The defaults are deliberately unglamorous. At least 100 closed trades matters more than any of the others, because a strategy with eleven trades can show almost any statistic by chance.
Why every goal has two numbers
The single most common way a backtest misleads is that the rules were shaped, consciously or not, around the very bars they were tested on. Run enough variations against the same history and one of them will look good on it, whether or not it captures anything real. The builder's defence is to split the history. The earlier part, 70% or 50% of the bars, is in sample. The later part, 30% or 50%, is out of sample. Every goal carries a threshold for each, and a goal only counts as met when both windows pass.
The out-of-sample thresholds can be set looser than the in-sample ones, as the defaults do for drawdown and profit factor, because a strategy that holds up on later data usually holds up less well than on the data it was found on. What matters is that it holds up at all. A script that clears every goal on the earlier bars and collapses on the later ones never counts as passing, however good the first half looks. The panel says it plainly under the goals: a goal counts only when both pass, and this is a simulation of the past, not a forecast.
What happens on each attempt
Each attempt follows the same steps, and the panel shows which one it is on. Writing the strategy: the model writes one Pine Script v6 strategy from your description and submits it with a short description of its rules. The script is then checked by the same linting engine that checks every script in PineScripter. If it does not compile, the model gets one chance to fix it, and an attempt that still does not compile is counted as failed and never simulated. Running the simulation: the strategy is simulated on the market and bars you chose, with your capital and costs. Checking the goals: every goal is measured on both windows.
The attempt then gets a score from 0 to 100. Most of it, 75 points, is the share of goals met on both windows. The remaining 25 points reflect how far past or short of each threshold the figures landed, so between two attempts that meet the same number of goals, the one with more margin ranks higher. The best attempt so far is kept, and the next attempt starts by picking up from it rather than from scratch. That is the loop: write, check, simulate, score, revise.
When it stops, and what you get
A search ends for one of a few reasons, and the panel says which. It ran out of the time you gave it, from 30 minutes to four hours. Enough scripts passed every goal on both windows, from one to five, as you chose. It made 60 attempts. Three attempts in a row failed outright. Or the account ran out of credits, since every attempt is an AI request and uses credits like any other. You can also stop it yourself at any point.
What you get is the closest script, opened in the editor, with its attempts and passes counted, and a report you can read the way you would read any simulation report. From there it is an ordinary PineScripter script: you can run it on the chart, step through its trades in replay, run the look-ahead check, simulate it on other markets and timeframes, ask the AI to change a rule and see the diff, and paste it into TradingView. The builder's own wording sets the right expectation: the score only says how close it came to the goals you set.
What a passing result does not mean
A script that passes has a specific, limited meaning: on these bars of this market, with these costs, its simulated figures met your thresholds on both the earlier and the later stretch. It does not mean the strategy works, and it does not say anything about what it will do next. Markets change, and two windows of one market's history are still one market's history. The builder also ran many attempts to find it, and the more versions a search tries, the more likely it is that one of them looks good by chance, even with an out-of-sample check.
So treat a pass as the start of your own checking, not the end of it. Read the rules and make sure you understand why they should do what they do. Simulate the script on other markets and timeframes, which PineScripter can do in one go. Step through its trades in replay and run the look-ahead check, which catches scripts that only look good because they read bars they should not have. And keep in mind that the simulation fills orders on historical Binance spot data under the costs you set; real fills can differ. PineScripter never places trades and never tells you to take one.
Getting good searches out of it
Write the description as rules, not as a hope. "Long when the close breaks the 20-bar high, exit on a close back inside" gives the search something to vary. "A strategy that does well on BTC" gives it nothing to hold on to. Keep the trade count goal meaningful for the timeframe and history you chose, because a high bar on a short history forces the search toward strategies that trade constantly. Use the 50% out-of-sample split when you have enough bars, since a longer second window is a harder and more honest test. And set costs you actually expect to pay: a strategy that only passes with zero commission and slippage has not passed.
Finally, give it a sensible amount of time. Thirty minutes is enough to see whether your idea has any version that meets the goals. Four hours is for when it is close and you want the search to keep refining. Either way, the script that comes out is code you own, in an editor where every rule is visible and changeable.
Frequently asked questions
What is PineScripter's AI strategy builder?
A search on the Ultra and Power plans that writes Pine Script v6 versions of a strategy you describe, simulates each one on historical crypto data with your capital and costs, scores it against goals you set on an earlier and a later stretch of bars, and revises from its best attempt until time runs out or enough scripts pass.
What is out-of-sample testing in the strategy builder?
The later 30% or 50% of the bars is held out as a second window. Every goal has a separate threshold for it, and a goal only counts as met when both the earlier and the later window pass, so a strategy that only fits the bars it was shaped on does not count.
Does a passing strategy mean it will work in live trading?
No. A pass means its simulated figures met your thresholds on both windows of that market's past bars, with the costs you set. It is a description of the past, not a forecast, and many attempts were tried to find it. Check it further on other markets, in replay and with the look-ahead check.
How long does a strategy search run?
You choose 30 minutes, 1 hour, 2 hours or 4 hours. It can stop earlier once the number of passing scripts you asked for (1 to 5) is reached, after 60 attempts, after three failed attempts in a row, or when the account runs out of credits.
Which plans include the strategy builder?
Ultra and Power. A search runs many AI requests and simulations in a row, and each attempt uses credits like any other request.
The practical takeaway
The strategy builder takes the most tedious part of strategy work, write, test, tweak, repeat, and hands it to an agent with a rule built in: nothing passes unless it also holds up on later bars it was not shaped on. That makes it faster and more honest than tuning by hand. It does not make a passing script a prediction. Read the rules it wrote, test them further, and keep the decisions about real money with you.
The strategy builder sits beside the chat in PineScripter on the Ultra and Power plans. Describe the rules, set goals on both windows, and open the closest script in the editor when the search ends.
Sources
Related reading: what PineScripter is, profit factor explained, max drawdown in a backtest, why backtests differ from live, slippage and commission.
Disclaimer: PineScripter is a coding tool for Pine Script development. It does not provide financial advice and does not guarantee trading profits. Always backtest strategies thoroughly and understand the risks before live trading.