Bot Builds

How to write rules a bot can follow

A bot only does what's written down. Most rules I get make sense to the person who wrote them and still leave a coder guessing.

Put a number on every word

Dip, strong, breakout, near the high. They feel exact when you trade by hand, but a bot can't read them. Each one needs a number or a line on the chart. A dip could be a 15 minute candle closing under its 20 candle average, or a drop of a set amount from the open. Which one is up to you. It just has to be one of them.

Say which candle, which price and which clock

Write the candle size and whether you mean the close, the high or the last trade. Write the time zone too. 10:00 in New York and 10:00 where you live aren't the same thing if you're out west.

Every entry needs an exit

The bot has to know how each trade ends. That can be a stop, a target, a time of day or a mix. Say what happens if the stop and the target both get hit inside the same candle, because a backtest has to pick one.

Answer the small stuff

Write down the most trades it can take in a day, whether it can hold more than one position, what it does on half days, and what it does if an order only partly fills. The bot runs into all of these in its first week.

Leave out anything that needs judgment

"Skip days that feel choppy" can't be coded. Make it exact or drop it. The example spec has one like that at the bottom so you can see how it gets handled.

See a full example spec with made-up rules.

If you want help getting yours exact, that's what the strategy session is for. I explain the common choices side by side and you pick every rule.

Education and software, not financial advice. Trading can lose money. Options can lose 100%. Genie Trades is not affiliated with or endorsed by Interactive Brokers.