Back to blog
October 14, 20268 min read

Defining Trading Strategy Rules So a Bot Can Actually Execute Them

Anyone setting out to define trading strategy rules for a bot quickly finds that a strategy traded by hand for months feels unambiguous - until someone has to program it. That's when it shows how many decisions were quietly being made in your head. A bot can't improvise. Every gap in the rule set turns into either a question back to you or an assumption by the developer - the first costs time, the second can cost a great deal more.

The test: would two developers write the same code?

A rule is unambiguous when two people implementing it independently reach the same result on every single bar. Buy on a breakout above the high fails that test: which high? Is a touch enough, or does a bar have to close above it? How far beyond counts as a breakout, and on which bar is the trade placed? Each of those questions has several reasonable answers - and each one produces different trades.

Entry rules that almost always need sharpening

  • Breakout: is touching the level enough, or must a bar close beyond it - and how far beyond?
  • Reference points: which high exactly - the prior day's, the current session's, or the last twenty bars'? And when does the day actually start?
  • Indicator conditions: oversold needs a threshold, a period, and whether the value must cross the threshold or merely sit below it
  • Timing of evaluation: is the trade placed after the bar closes, or as soon as the condition is met mid-bar? That's the difference between a stable signal and a flickering one

Exits and risk: more than stop and target

  • Stop and target in ticks, points, percent or relative to a structure - always with an example value so units can't be mixed up
  • Trailing the stop: from when, in what steps, and based on which bar
  • Time exit: whether a position is closed at the session end or after a set duration
  • Position size: fixed, calculated from risk per trade, or adjusted to volatility

Want your strategy automated?

Send us the description as it stands - we'll work through the open points together. The feasibility check and quote are free and non-binding.

Request a project

The edge cases almost nobody thinks of

The real gaps rarely sit in the entry. They sit in situations that come up so seldom in manual trading that you resolve them on instinct. A bot needs an explicit answer for each:

  • Stop and target both hit within the same bar: bar data alone can't tell you which came first. The rule set and the backtest need a fixed assumption for it
  • New signal while a position is open: ignore it, add to the position, reverse, or close the existing one?
  • Opposite signal: does a signal in the other direction end the running position, or only the stop and target?
  • Partial fill: what happens if a limit order is only partly filled - leave the rest working, chase it, or cancel?
  • Restart: how does the bot behave when it's restarted with a position already open?
  • Clustering: is there a maximum number of trades per day or per session, and does it still apply after a loss?

What else belongs in the description

  • The market, contract and timeframe the strategy is meant to run on
  • Trading hours in exchange time, including behaviour shortly before the close
  • One or two chart screenshots with marked examples - a picture often clarifies more than a whole paragraph
  • Which values should be adjustable later and which may stay fixed in the code
  • The desired outcome: an indicator with signals, an alert, or a fully automated bot

For how such a description becomes a finished bot step by step, see the article on automated trading strategies on ATAS.

For why the timing of evaluation matters so much, see the article on repainting.

Frequently Asked Questions

Do I need to know how to code to describe my strategy?

No. What's needed is a precise description in plain language, not lines of code. What matters is that every condition is phrased so it can be answered with a clear yes or no on every bar.

What if my strategy involves discretion?

Parts that rest on experience or feel can't be automated directly. Often there's a measurable approximation, though - or the bot handles only the unambiguous part and flags the rest via an alert for a manual decision.

How detailed should the first request be?

For an initial feasibility check, entry, exit and market are enough. The edge cases can be worked out together afterwards - the earlier they're on the table, the more precise the quote.

Can I change the rules later?

Yes. How much work that is depends on how fundamental the change is: a different threshold is adjusted quickly, new logic for open positions isn't. That's why it pays to settle the edge cases in particular before work starts.

An unambiguous rule set isn't a formality, it's the precondition for the bot trading what was actually meant. The time spent on edge cases is almost always shorter than the time a single wrong assumption costs later.

Have an idea for ATAS?

Tell us about your project - you'll get a free, non-binding quote within 24-48 hours.

Request a Free Quote