Trading Education

How to Set Up a Trading Bot

Listen to this articleAI-generated voice
0:00 / –:––

The candle closes above its moving average. The entry rule passes. The bot skips the order anyway.

That’s the first paper test I’d run. Can I open the log and see exactly what happened? Here’s a small example, from writing the rule to reading the result.

What is a trading bot?

A trading bot is software that applies a set of rules to market data. Depending on how it is set up, it can flag a signal, record a simulated decision or send and manage orders. Automation makes it easier to apply the same rules consistently, even when you are away from the screen.

The bot reads inputs such as price, volume or indicator values, checks the entry or exit conditions, then applies the relevant risk limits. Its log can record what happened, including skipped signals and failed orders. It can repeat that process quickly, but the result still depends on the rules, the data and the execution.

Start with one rule

“Buy when price looks strong” could mean half a dozen things. Give the bot a time to look and two numbers to compare. Here’s the whole entry check for our example.

When
After each one-minute EUR/USD candle closes.
Check
Is the latest close above the average of the last five closes, including this one?
Next
If it is, run the risk check and write the decision to the paper test log.

A candle can poke above the line and close below it. That little phrase “after it closes” decides whether that candle ever shows up as a signal.

Why the bot sat out

A signal can pass and the order can still get skipped. In this test, the account is already down $32 on closed trades today. The daily limit is $30. There’s your reason, right in the log.

The day’s realized P&L is −$32 against a $30 daily loss limit. The bot skips the order.

“Daily” needs a definition. When does the day reset? Do open positions count toward the limit? In this example, the limit blocks new entries. Any open position keeps its own exit rules.

Types of trading bots

  • Trend following. Looks for sustained moves, often using moving averages. It can generate repeated false signals when prices move sideways.
  • Grid. Places buy and sell orders at spaced price levels. In a range, repeated swings can cross the same levels in both directions. A breakout can leave the bot holding a growing position.
  • Arbitrage. Looks for a price difference between markets or related instruments. Fees, delays or a fill on only one side can erase the difference.
  • Market making. Quotes a bid and an ask, usually in liquid markets, and seeks to earn the spread when both sides fill. One-sided fills can build inventory just as the price moves against it. A fast counterparty can also trade against a quote that no longer reflects the market.
  • Signal based. Acts when an indicator such as RSI or MACD meets a defined condition. The EUR/USD example uses a moving-average rule.

How to compare trading bots

  • Rules and records. Look for readable rules and a log that shows the inputs, decisions and order status. Trace one skipped signal and one simulated fill from start to finish.
  • Setup and upkeep. A no-code builder lets you configure rules through menus, but check that it can express your exact timing, entry and exit rules. A scripted tool can offer more flexibility and requires someone who can test, debug and maintain the code.
  • Simulator and data. Check the instruments, intervals and indicators you need. Compare data coverage and timestamps, and check how the simulator models order fills and fees. Check whether historical data or exports cost extra.
  • Tool costs and trading costs. Compare one-time license fees, subscriptions, and charges tied to usage or hosting. Track them separately from commissions, the bid–ask spread and slippage on trades. A tool with no subscription can still incur trading costs.
  • Permissions and credentials. Use read-only data access or dedicated test credentials with limited permissions. Keep secrets out of code and logs, and check that you can revoke access. Leave transfer and withdrawal permissions disabled.
  • Claims and venue rules. Treat promises of guaranteed returns as a warning sign. If your test models a particular venue, review its published rules on automation, data use and order handling.

How to set up a trading bot step by step

Start with a strategy you can explain, an indicator you understand and a simulator with the data you need. Check how the simulator timestamps candles, models fills and handles a lost connection. Write down the behavior you expect before you configure it.

  1. Define the strategy. Choose the instrument, timeframe and market conditions you want to test.
  2. Set the data and indicator inputs. Specify the session time zone, indicator settings and how much completed data must be available.
  3. Write the entry and exit conditions separately. Define when a signal counts, what order it represents, and what closes the position, such as a stop, a target or a time limit.
  4. Set risk limits. Specify position size, maximum open positions or trades per day, and what the daily loss limit should block. Decide what happens to pending orders when the bot pauses.
  5. Test in stages. Log decisions first, then run a backtest and a forward test with simulated orders. Compare the recorded actions with the written rules.

For the EUR/USD example, select one-minute candles and load at least five closed candles. Check that the first evaluation uses the latest close and the average of the five closes ending there.

Try the parts that are easy to forget. Pause the bot with a simulated order pending and see what happens to that order. Let the data go stale and check that the bot waits and tells you why.

A stop order that triggers a market order can fill at a different price from its trigger. That’s one reason to look at the fill as well as the signal.

One trade, two sets of prices

A backtest plays your rule against old data. It also has to pick a price for each fill. If your rule needs the close, start by checking that the test only uses the close once it’s available.

Here’s a separate trade. At the chart prices it gains 1.2 pips. The simulated buy fills 0.6 pip higher and the sell fills 0.7 pip lower. Now it’s down 0.1 pip, before commission.

The same trade moves from +1.2 to −0.1 pips in this example. Commissions are separate.

The hollow dots are the chart prices. The solid dots are the simulated fills. If those fills already include the spread, use those prices to work out the result. Then apply commission separately.

Save a later stretch of data for the rule you end up with. Pick your settings on the earlier stretch, then test them on the later one without changing them.

Read the win rate alongside the average gain and loss, the number of trades and the largest drop from a previous peak. Compare results across rising, falling and sideways markets. Try wider spreads or worse fills to see how much the outcome depends on the execution assumptions.

Let the next candle arrive on its own

That’s a forward test. The data comes in live and the orders are simulated. Write down what you expect first, then look for these three entries in the log.

  • A match. Which close did the bot read, what did it compare it with and what action did it take?
  • A skip. Which limit stopped the new order?
  • A gap in the feed. Did the bot wait? After it reconnects, compare its log with the simulator’s order history before letting it send anything new.

A dry-run checklist

  • Stale data. Block new entries when the feed exceeds the data age limit you set. Check that the log records why and that entries stay blocked while the feed is stale.
  • Restart and recovery. Restart with a simulated order pending. Reconcile saved state with the order and fill history, then check the open position size and daily loss counter before accepting another signal.
  • Duplicate and partial fills. Replay a signal and an order acknowledgment. Check that the signal generates at most one order and the repeated acknowledgment leaves quantities unchanged. With a partial fill, verify that exits use the filled quantity.
  • Alerts and readiness. Set alerts for lost data, rejected orders and unexpected position sizes. Keep testing until you can explain every mismatch and confirm the pause prevents new entries.
  • False confidence. Automation can make exposure feel smaller because the bot handles execution. Keep position-size and loss limits fixed during a test. Treat any proposed increase as a new risk assumption that needs its own test.
  • Monitoring and pause. Before a supervised test, agree who reviews order status, fills and exposure, and who can pause the bot. Watch the first simulated runs closely and review the log regularly. Use simulated orders to rehearse what happens to pending orders and open positions after a pause. A clean run shows how the rules behaved under the conditions you tested.

What to check when a test goes wrong

  • A signal is missing. Check the symbol, time zone and candle close. Verify that the feed is current and has enough data to calculate the indicator.
  • An order is late or rejected. Compare the signal time, the send time and the simulator response to see where the delay or rejection occurred.
  • Losses cluster after a sharp move. Review fills, spreads and repeated signals around the move. Compare position size and drawdown with the limits you set.
  • The forward test diverges from the backtest. Compare data, timing, fees and fill assumptions first. Keep a copy of the settings and retest changes on a separate period.

Read the log backwards

Pick one fill and one skipped signal. Start with what happened, then work back to the rule, the risk check and the timestamp on the data. If you get stuck, you’ve found the next thing to fix.

Keep the rule and the simulator settings with that log. When you change something, run the same little test again. It’s much easier to see what moved when you have the old result beside it.

Mauricio Diaz

Lead Trading Educator

Mauricio came to trading education through six years of customer-facing work in the trading industry - which means he knows exactly where beginners get stuck, because he has talked to thousands of them. Based in Latin America, he has a particular depth in regional market dynamics and trader behaviour. At IQ Option, he writes across the full educational range: foundational concepts, platform guides, algorithmic trading, AI tools, and automated strategies. He holds a degree in Industrial Engineering from Escuela Colombiana de Ingeniería in Bogotá.

View on LinkedIn ↗

Frequently asked questions

Do I need coding skills to set up a trading bot?

Some tools let you build simple rules without code. Custom integrations or order logic may require programming. Either way, write down what data the bot reads, when it may act and what stops it.

Can a trading bot guarantee profits?

No. Results depend on the strategy, market conditions, data, execution and trading costs. Backtests and simulations cannot guarantee future profits.

How much money should I start with?

There is no standard starting amount. You can learn the setup and test your rules in a simulator with virtual funds. A stable simulation does not tell you what to risk in a live account.

Should I monitor my trading bot?

Yes. Watch for stale data, rejected or duplicate orders, and risk limits that have been reached. After a restart, check that the bot’s log matches the order history before it resumes.

What markets can I use a trading bot on?

Automation is available for some stocks, currencies, cryptoassets and commodities. What you can automate depends on the venue, instrument and account rules. Check those rules before connecting a tool.