AI Strategy Generator
The Generate with AI button on the New Strategy dialog turns a plain-English description into a Blockly workspace you can edit. It's a fast way to get past the blank-canvas stage of building a strategy — describe what you want, and the AI assembles the indicator references, conditions, entries, exits, and risk-management blocks for you.
A clear, detailed description gives you a strong starting point. From there you'll review the result and tweak it to match exactly what you had in mind — same as you would with any draft. Most strategies need a few small adjustments before they backtest cleanly, and that's where you get to apply your own judgement.
How it works
When you click Generate with AI, the platform sends the AI your prompt along with your configured indicators, signals, formations, and the Default Trading Source — so make sure those are defined before generating.
Concretely:
- Configure any indicators, signals, or formations the strategy will need first. The AI works with what's already in your catalog, referencing them by name.
- Set the Default Trading Source on the New Strategy dialog (exchange, symbol, timeframe) before generating. The AI uses it whenever your prompt doesn't name a market explicitly.
Writing a good prompt
Specifics produce specifics. The more concrete your description, the closer the result will be to what you want.
A good prompt usually covers:
- Trading mode — spot, margin, or futures (with leverage).
- Market — symbol, timeframe, exchange (only needed if it differs from the Default Trading Source).
- Which indicators, signals, or formations to use, by exact name.
- Entry conditions — concrete numeric thresholds, separate for long and short if both apply.
- Exit conditions — separately for long and short. "Close when RSI > 50" is ambiguous if both sides exist; "close LONG when RSI > 50, close SHORT when RSI < 50" is clear.
- Risk management — stop loss %, take profit %, position size (% of equity or fixed amount).
- Anything you want to exclude — for example, "use the formation as a circuit breaker only, never as an entry signal."
The tutorials section includes working AI prompts you can adapt.
What you'll get back
The generator is good at turning a clear description into:
- The blocks that build your strategy logic, ready to edit on the canvas.
- References to the indicators, signals, and formations you've already configured.
- Sensible entry, exit, and risk-management structure when you describe it concretely.
A few common things you'll want to adjust afterward:
- Same-bar entry and exit. If your entry and exit conditions can both be true on the same candle (e.g.
RSI < 40to open andRSI < 50to close), the position will open and close immediately. Widen the thresholds so the two ranges don't overlap. - Direction-aware exits. When long and short use different exit conditions on the same indicator, add
in_longandin_shortflags so a long exit doesn't accidentally fire the short close. The Formations as Circuit Breaker tutorial walks through this pattern. - Stop loss / take profit on shorts. A "5% stop loss" applied to a short needs to sit above entry, not below. Glance at the SL/TP blocks and confirm they make sense for both sides.
- Per-indicator source. If different indicators run on different timeframes or symbols, double-check each indicator's source block. The AI may have assumed they all run on the default.
These are normal post-generation passes — none of them mean anything went wrong. Treat them as part of the workflow.
After it generates
Before you backtest, walk through:
- Read the blocks. Trace entry → exit → risk management and confirm each block matches what you asked for.
- Default Trading Source on the dialog still matches what you wanted.
- Direction-aware exits if you trade both sides.
- Same-bar thrash check — entry and exit ranges shouldn't overlap.
- Risk-management blocks are present and point the right way for shorts.
Then backtest it. The backtest will surface anything subtle.
Errors you might see
- "indicator 'X' is not configured." The AI referenced an indicator that isn't in your catalog. Either add one with that exact name, or edit your prompt to use one you already have.
- "formation 'X' is not configured." Same idea — draw the formation on a chart first.
- "AI took too long" / timeout. The generator has about a four-minute window. Very long or complex prompts can occasionally exceed it; shorten or simplify and try again.
- Generic "failed to generate" error. The AI returned something that didn't validate cleanly. Simplify the prompt and retry. If a particular section keeps tripping it up, build that part by hand and use the AI for the rest.
Errors appear inside the AI dialog and your prompt stays in the box, so you can adjust and click Generate again without retyping.
When it's most useful
The generator earns its keep when:
- You know what strategy you want — entries, exits, risk — and writing the prompt is faster than dragging blocks.
- You want a structural starting point you'll refine afterward.
- You're translating a strategy from another platform or a written spec.
It's less useful when you're still figuring out what the strategy should do — prompting an AI to invent a strategy you can't articulate yourself produces strategies you can't evaluate. In that case, the Trading Mindset and Strategy Patterns guides are a better place to start.
The golden rule applies either way: build → backtest → paper trade → live. Generated code goes through every step the same as hand-built code.