Strategy building

How to start algorithmic trading

Summary

An algorithm turns a trading idea into repeatable decisions. Write down which prices it observes, when it enters and exits, and how large a position it takes. Before running it, try a few prices by hand so you know which trades you expect to see.

A row of ivory dominoes tipping in sequence on a blue surface.

A trading idea becomes easier to examine when you write down exactly what would make you act. What should you buy? When should you enter? What would make you sell? How much should each decision involve?

Algorithmic trading puts those decisions into rules that software can follow. The practical starting point is a small strategy whose behavior you understand well enough to check.

You can begin with visual tools in Alphavator, learn how your rules behave in historical tests, and observe them with simulated money before considering live execution.

What algorithmic trading means

An algorithm is a defined sequence of instructions. In trading, software may use those instructions to evaluate data, size positions, or submit orders. The SEC staff report on algorithmic trading describes a broad range of applications, including decisions about instruments, order size, timing, and execution.

For a beginner, a daily rule is enough to explore the concept. You do not need a strategy that reacts thousands of times a second.

Automation makes a decision repeatable. Whether that decision is sensible depends on the strategy, data, implementation, and market conditions. A mistaken rule can also be repeated consistently.

Write a complete strategy specification

Before opening a builder, fill in six decisions:

  1. Market: Which assets may the strategy trade?
  2. Observation: Which data and timeframe does it use?
  3. Entry: What exact condition allows a purchase?
  4. Exit: What exact condition closes the position?
  5. Size: How much simulated capital can the strategy use?
  6. Operation: When are conditions evaluated, and what happens if data or orders are unavailable?

This exercise reveals gaps that a persuasive description can hide. “Buy strong stocks and manage risk” sounds reasonable, but it leaves the actual decisions open.

An example of precise trading rules

Consider this hypothetical moving-average specification for learning:

  • Observe one supported asset on a daily timeframe.
  • Calculate 20-day and 50-day simple moving averages using completed daily closes.
  • When no position is held, enter if the 20-day average is above the 50-day average.
  • Use 10% of available simulated cash for one entry; do not add while holding.
  • Exit the entire position if the 20-day average is below the 50-day average.
  • At equality, keep the existing position state.

The numbers are educational choices, not optimized settings or an investment recommendation. The example uses the state of the averages. It can enter when the strategy starts if the faster average is already higher.

A crossover rule is different: it requires the faster average to have been at or below the slower average on the previous observation and above it on the current one. Decide which behavior you want. That distinction can change the first trade and every later entry.

The specification still needs an execution assumption: when does an order become eligible after the completed daily data is known? Check the platform's behavior before interpreting a simulation.

Eight schematic observations show a fast value reaching the slow value at observation three and crossing above at observation four. Fast above slow remains true at observations four, five, and six, while the crossing event is true only at observation four.
Figure 1. An above condition can stay true across several observations. A crossing event requires a transition: the previous fast value was at or below the previous slow value, and the current fast value is above the current slow value. The illustrated values are schematic, not actual moving averages.Full size — Eight schematic observations show a fast value reaching the slow value at observation three and crossing above at observation four. Fast above slow remains true at observations four, five, and six, while the crossing event is true only at observation four. (opens in a new tab)

Build a first TBOT in Alphavator

A TBOT is an automated trading strategy in Alphavator. Create one with visual blocks, or describe your idea to the AI and review the supported rules it drafts.

  1. Set the asset and timeframe. Make sure they match your written specification.
  2. Build the entry conditions. Check indicator lengths, price inputs, comparison signs, and how multiple conditions combine.
  3. Build the exit conditions. Confirm how much of a holding each sell action closes.
  4. Review sizing and position behavior. Check what happens when a condition remains true and when a position already exists.
  5. Read the complete strategy. Explain an entry, an exit, and a situation in which it should do nothing.

Visual blocks make it possible to inspect the relationships between conditions. Use that visibility: the test should evaluate the strategy you intended, including the parts an AI draft may have interpreted differently.

Move through three kinds of testing

First, backtest. Apply the rules to historical data and inspect individual trades. Check the simulation's timing, costs, and treatment of data. A large return with unexplained trades is a reason to investigate.

Next, evaluate unchanged rules on a separate period. Record the strategy before looking at those results. If you keep altering it in response, you are still developing it.

Then, paper trade. Observe the strategy as new data arrives, using simulated funds. Check whether signals, orders, and holdings behave as expected. A strategy that trades rarely needs enough observation opportunities to make this exercise useful.

These stages answer different questions. Historical tests examine past behavior under modeled assumptions. Paper trading helps you inspect the operating process going forward. Neither establishes future profitability.

Know what you are handing to automation

Before considering live execution, you should be able to describe the maximum intended exposure, how the strategy exits, and when you would stop and investigate it.

Confirm how to review open orders, broker positions, and strategy status. Verify what pausing or stopping a TBOT does to existing orders and holdings; do not assume it automatically cancels everything or sells a position.

Consider specific problems: a rejected order, a missing price update, a delayed signal, or a position that differs from the one you expected. Establish a review routine and learn the platform and broker procedures for resolving them.

Live execution through Alphavator requires a supported brokerage connection and applicable account permissions. Connecting a broker and enabling a strategy are meaningful decisions, so complete your review first.

Step-by-step walkthrough

In the recording, a QQQ strategy checks two entry conditions together and can exit on either of two conditions. Read its buy and sell blocks from top to bottom, then test which daily closes would leave the bot in cash.

Jump to a step
  1. Start with one symbol and one interval
  2. Make “strong” measurable
  3. Separate the buy decision from its size
  4. Decide what gets you back to cash
  5. Check your algorithm against the chart
  1. Step 1

    Start with one symbol and one interval

    In Alphavator, open Discover, select Create New TBOT, then choose Technical. A Technical TBOT is a trading robot whose rules can use prices and indicators. Give yours a recognizable name such as “QQQ daily breakout”. Choose 1 day and add QQQ under Select Symbols. Check that its chart appears.

    At this interval a 200-period simple moving average, labeled SMA, is the average of 200 daily closing prices. On a five-minute chart the same length would describe 200 five-minute bars. Pick your interval before choosing the length.

  2. Step 2

    Make “strong” measurable

    In Set Buy, add a Condition. Put CURRENT_PRICE on the left, choose greater than, and put SMA on the right. Set its length to 200 and its input to Close. This is the trend requirement. A rally can pass this first test while it is still below the upper band.

    Add a second Condition to the same group. Choose CURRENT_PRICE greater than BBANDS and select the Upper output. Use Close, a length of 50, an SMA basis, and a standard deviation multiplier of 2.1. That multiplier sets the distance from the 50-day average in units of recent price variability. With both conditions above the same buy action, QQQ must pass both tests.

    Set Buy with two greater-than conditions, for SMA and the upper Bollinger Band, above a QQQ Weight block.
    Read from the top down. Both conditions have to be true for the QQQ Weight action below them.Full size — Set Buy with two greater-than conditions, for SMA and the upper Bollinger Band, above a QQQ Weight block. (opens in a new tab)
  3. Step 3

    Separate the buy decision from its size

    Under the two conditions, add a Weight block for QQQ. The example sets a 100% target, so a qualifying buy aims to put the simulated portfolio into one fund. A 25% target would aim to put about $2,500 of a $10,000 simulated portfolio into QQQ instead. Position size changes what a price move means for the account.

    Try a pencil test. Suppose the 200-day average is $395 and the upper band is $405. From cash, a $400 close leaves you in cash. A $405 close also leaves you there, because the comparison is strictly greater than. A $406 close qualifies for the buy. If you expected a buy at $405, you have just found a difference between your intention and the rule.

  4. Step 4

    Decide what gets you back to cash

    In Set Sell, choose CURRENT_PRICE less than the Mid output of the same Bollinger Bands. Place a QQQ Weight of 0% below it. Add an alternative branch for CURRENT_PRICE less than the 200-day SMA, with its own QQQ Weight of 0%. Look for OR between the branches.

    Imagine you already hold QQQ. It closes below the middle band but stays above the 200-day average. Would you expect to sell? Here the answer is yes. Either exit is enough. Putting both conditions above one sell action would make the robot wait until both were true.

    Set Sell showing separate Bollinger Mid and SMA exit branches joined by OR, each with a zero-percent QQQ weight.
    The OR between the two branches gives the strategy two ways to close its position.Full size — Set Sell showing separate Bollinger Mid and SMA exit branches joined by OR, each with a zero-percent QQQ weight. (opens in a new tab)
  5. Step 5

    Check your algorithm against the chart

    Select Create to save the TBOT. In Backtest, choose dates with daily QQQ history, enter simulated starting cash, and select Run Backtest. Find a buy marker and the next sell marker. Describe each decision in a sentence using the prices and indicators on the chart.

    For a second experiment, change only the target weight in a separate version. Use the same dates and starting cash. Would you expect the buy conditions to become true on different days, or would you expect the size of the portfolio swings to change? Make your prediction first, then check the two results in Alphavator.

Try this in Alphavator

Further reading · John Bollinger’s guide to interpreting Bollinger Bands

Frequently asked questions

Do I need to learn Python first?

You can use Alphavator's visual builder and AI assistance for supported strategies without writing Python. Coding becomes relevant when your research or execution requirements exceed the available tools.

How much money do I need to get started?

You can start learning through historical tests and simulated trading. Any later live account requirements depend on the broker, instruments, account type, and strategy. There is no universal starting amount suitable for everyone.

Is a more complicated algorithm better?

Extra conditions create extra decisions to verify. Add a condition when you can explain its purpose and evaluate its effect. Complexity alone offers no evidence of an advantage.

Make your first idea testable

Write one entry, one exit, and one sizing rule. Build the strategy in Alphavator and check that the blocks say what you mean. Completing that small exercise gives you a practical foundation for learning algorithmic trading.

Next, learn how to backtest the strategy, explore quantitative stock selection, or try paper trading.

For education and product demonstration. Examples are hypothetical. Trading involves risk, including loss of capital.