Strategy building
How to use AI to create a trading strategy
Summary
Give the AI a rule precise enough to test by hand. Specify the asset, timeframe, entry, exit, and position size, then check the generated blocks against your instructions. A trade that fires too early or repeats unexpectedly tells you which part of the draft to revisit.

You may understand a trading idea in plain English and still struggle to turn it into rules a system can execute. “Buy when the trend looks strong” makes sense in conversation. It leaves a trading bot with unanswered questions.
Which trend measurement? Which timeframe? How much should it buy? When should it exit?
AI can help translate an idea into a structured draft. The useful outcome is a strategy you can explain, inspect, and test. In this tutorial, you will write a precise prompt, review the result in Alphavator, and decide whether the implementation matches what you asked for.
What AI contributes to the process
Alphavator's AI-assisted strategy builder helps draft and refine rules that you can review in visual blocks. This can make it easier to move from a description to a testable configuration.
Keep a separate question in mind: are these the right rules to study? A well-formed strategy can still perform poorly. A convincing explanation can also contain an error. The joint SEC, FINRA, and NASAA investor alert on AI warns that AI-generated information can be inaccurate, incomplete, or fabricated.
Use the draft as something to examine. You remain responsible for the trading rules and any decision to use them.
Give the AI a clear specification

A useful prompt identifies the security or universe, timeframe, entry rule, exit rule, position size, and trading constraints. It also explains what should happen when no action is required.
For an introductory exercise, keep the logic small enough to check manually. A simple moving average, or SMA, is the arithmetic average of a specified number of observations. For a 50-day SMA of closes, add the most recent 50 daily closing prices and divide by 50.
The following AAPL example is an educational specification, not a recommendation to buy the stock or use these parameters. Its 10% allocation is a hypothetical input for the exercise.
Create a long-only AAPL strategy for educational backtesting using completed daily candles and a 50-period simple moving average of closing prices.
When no AAPL position is held, enter if the completed daily close is strictly above the SMA. Use 10% of available cash for one entry. Do not add to an existing position.
Exit the full AAPL holding when the completed daily close is strictly below the SMA. If close equals the SMA, take no action. Begin in cash. Do not short or use leverage.
Use completed bars for the signal. Explain when the strategy evaluates the conditions and what execution price the backtest assumes. Flag any difference between the simulated fill and an order placed after the completed signal becomes available.
Explain the rules and show the corresponding blocks. Identify unsupported conditions, timing assumptions, and missing information before proceeding. Do not silently substitute different rules, add a stop, or claim expected returns.
This prompt describes the requested behavior. Whether every detail can be represented must be checked against the current builder and execution model. If a requirement is unsupported, revise the experiment explicitly before testing.
Build the draft in Alphavator
- Start a new TBOT. From Discover, choose the option to create a new TBOT and then create with AI.
- Enter the specification. Paste the prompt and review any questions or limitations the AI identifies.
- Read the explanation. Open the full explanation when available. Compare its instrument, timeframe, entry, exit, sizing, and timing with your original specification.
- Inspect the visual blocks. Check each condition and action. Resolve any difference between the explanation and the implemented configuration.
- Save the version you intend to test. Give it a descriptive name and record its parameters so later comparisons remain meaningful.
The goal at this stage is an understandable draft. A generated strategy is not evidence that the underlying idea works.

Check the details that change behavior
A condition and a crossing event are different. “Close is above the SMA” can remain true for many days. “Close crosses above the SMA” requires a transition from at or below to above. In our example, the no-existing-position requirement prevents repeated additions while the condition remains true. Confirm that the actual implementation enforces that behavior.
AND and OR change the set of eligible trades. If you later add “RSI below 30,” AND requires both the price condition and RSI condition. OR allows either one. Read the grouping as a sentence before running a test.
Position size and loss limits are different quantities. Allocating 10% of available cash does not create a 10% stop loss. This minimal example specifies no protective stop. Its closing-price exit can allow substantial losses within a position, especially if prices move sharply between observations.
Signal time and fill time must fit together. If a decision needs the completed closing price, that decision cannot also assume advance knowledge of that price. Verify the test's actual execution assumption. A same-bar close model should be disclosed and interpreted as an approximation, not described as next-session execution.

Test the implementation before judging the idea
Run a backtest over a clearly recorded period. First inspect a few entries and exits. Find the corresponding indicator values and check whether the action follows the rule. Investigate repeated purchases, missing exits, trades before indicator warm-up, or timestamps that do not fit the stated logic.
Only after that review should you examine performance. Consider drawdowns, trade count, trading costs, and a relevant comparison. A high ending balance cannot resolve an implementation error.
If you revise the strategy, change one meaningful element at a time and state the reason. A useful experiment might compare two predetermined SMA lengths. Repeatedly asking AI to improve the same historical result can steer the process toward choices that fit that particular sample.
Preserve a separate period for evaluation and move to paper trading when you want to observe new data. Neither stage guarantees future returns.
Step-by-step walkthrough
The recorded AAPL example compares two moving averages. It aims to hold the stock while the 50-day average is above the 200-day average, even if the crossing happened earlier. Inspect the assistant’s comparison blocks, then replace 50 with 20 and find the first trade that changes.
Jump to a step
Step 1
Give the assistant a rule it can build
In Alphavator, open Discover, select Create New TBOT, and choose Technical. A TBOT is a trading robot that holds your rules. Open the AI Strategy Assistant in the builder and paste this prompt.
“Build a long-only AAPL strategy using daily closing prices. While the 50-day simple moving average is above the 200-day simple moving average, target 100% in AAPL. When it is below, target 0% in AAPL. If they are equal, leave the position alone. Show me the entry, exit, and any assumptions.”
The weights make the experiment easy to follow. A 100% target means the model aims to invest its whole account in AAPL. A 0% target takes it back to cash. Both refer to the size of the position after the order.
Step 2
Check what happens the day after a cross
In Set Buy, find the 50-day SMA on the left of the greater-than sign, the 200-day SMA on the right, and a Weight of 100%. Set Sell should reverse the comparison and carry a 0% weight. Confirm that the symbol is AAPL and that both averages use daily closes.
Hold the slow average at $100 and try three values for the fast average. At $99 the strategy targets cash. At $101 it targets AAPL. If it is still $101 tomorrow, the buy condition is still true. In this backtest, keeping the condition true for a second day does not trigger a second buy. At exactly $100 neither comparison fires. If your draft behaves differently, tell the assistant which comparison to change.

Read across each condition to the Weight block. Together they tell you when the rule applies and how much AAPL the strategy aims to hold.Full size — Set Buy compares SMA 50 above SMA 200 with a 100% weight. Set Sell compares SMA 50 below SMA 200 with a 0% weight. (opens in a new tab) Step 3
Save a first run you can compare against
Name the TBOT and select Create. Open Backtest. To follow our example, use January 4, 2021 through December 31, 2025, $10,000 in Initial Cash, daily Resolution, and close for Price To Buy. Select Run Backtest. The example assumes zero fees and zero slippage, meaning the simulation fills the order at the modeled price.
Before you edit anything, write down a prediction. Would a 20-day average have sold sooner during a decline? Could it also have bought back too early? Now you have a reason to look at individual trades.
Step 4
Change 50 to 20 and find the first different trade
Change the fast SMA from 50 to 20 in both Set Buy and Set Sell. Leave the slow SMA at 200, select Update, and rerun the same dates and settings. Switch between the two results under Saved backtests. In our example, the 20-day version sold on May 12, 2022. The 50-day version held until June 3.
Over the full test, the faster version returned 47.55% and the original returned 8.28%. Yet the faster version also had the deeper fall from a previous high, 35.64% versus 32.69%. The SPY benchmark gained 84.85% over the same dates. Which rule would you carry into a second test given that trade-off? Write down your choice, then run it on a period you set aside before making the change.

The blue line is the 20-day version and the dashed line is SPY. Select the earlier saved result to see the 50-day version.Full size — Cumulative return chart for the 20/200 version, with a blue strategy line and a dashed purple SPY benchmark. (opens in a new tab)
Further reading · Fidelity’s guide to simple moving averages
Frequently asked questions
Do I need to know how to code
Alphavator provides visual blocks and AI assistance for supported strategies. You still need to understand the rules and verify that the configuration expresses your intent.
Can I ask AI to make a profitable trading bot
You can ask for ideas to investigate, but a profit request does not supply a testable specification or establish an edge. Ask for explicit rules, assumptions, and limitations, then evaluate the result.
What if the AI cannot represent part of my strategy
Identify the unsupported requirement and choose a deliberate revision. An omitted exit, changed indicator, or different execution assumption can create a materially different strategy.
Turn one idea into rules you can inspect
Create an AI-assisted TBOT in Alphavator and use the prompt above as a specification exercise. Review every block before deciding what to test.
Next, learn how to backtest your strategy, how to practice with paper money, or how to turn a YouTube strategy into explicit rules.
Educational content and hypothetical examples only. AI output and simulated performance do not guarantee investment results. Trading involves risk.