Docs

Writing a strategy AlphaBack understands

There is no syntax to learn, but there is a knack to being unambiguous. This is what the model reliably understands, what it does not, and how to phrase the awkward cases.

Anatomy of a strategy

A strategy AlphaBack can run needs two things: when to buy and when to sell. Everything else is optional. The shortest strategy that works is one sentence:

Buy AAPL when RSI drops below 30, sell when it goes above 70.

That is complete. It has an entry condition, an exit condition, and an instrument. You can add as much as you like on top — position sizing, stops, extra filters — but nothing more is required.

Say it out loud first. If a person could follow your sentence without asking a clarifying question, the model almost certainly can too. If they would ask "sell when what drops?", tighten it before you run.

Indicators it knows

Name any of these in plain words and the generated code will use them correctly. Periods are yours to choose — "the 14-day RSI", "a 200-day average".

  • Moving averages — simple (SMA) and exponential (EMA), any period. "the 50-day average", "the 200-day exponential".
  • RSI — "when RSI is below 30", "when the 14-day RSI tops 70".
  • MACD — "when MACD crosses above its signal line".
  • Bollinger Bands — "when price touches the lower band", "when it closes outside the upper band".
  • ATR — most useful for volatility-based stops: "with a stop two ATR below entry".
  • Highs and lows — "a new 20-day high", "the lowest close in three months".
  • Volume — "on volume above its 20-day average".
  • Raw price moves — "after it falls 5% in a day", "up three days running".

Entry and exit rules

Combine conditions with ordinary words. and, or, unless and only if all behave the way you would expect:

Buy when the 20-day average crosses above the 50-day
and RSI is under 60. Sell when either the averages cross
back or RSI goes over 75.

Two phrasings are worth being careful with:

  • "crosses above" is not "is above". A crossover fires once, on the day it happens. "Is above" is true every day until it isn't — which usually means you buy on day one and never trade again.
  • "drops 5%" needs a reference. Five percent from what — yesterday, the entry price, or the highest point since you bought? Say which. "Sell if it falls 5% below my entry price" is unambiguous; "sell if it drops 5%" is not.

Stops and sizing

Name these in the same sentence and they will be built into the strategy rather than bolted on:

  • Stop loss — "with an 8% stop loss", "stop out two ATR below entry".
  • Take profit — "take profit at 20%".
  • Trailing stop — "trail the stop 10% below the high since entry".
  • Position size — "put 50% of the account in each trade". The default is to use the full account on each entry.
Stops are checked once a day. Everything here runs on daily bars, so a stop triggers against the day's low, not the moment price crossed it. Real intraday fills will differ, sometimes badly on a gap.

Tickers and dates

Anything Yahoo Finance carries will resolve. Use its symbol format:

TypeFormatExamples
US stocks & ETFsPlain symbolAAPL, MSFT, SPY, QQQ
IndicesCaret prefix^GSPC, ^IXIC, ^DJI
CryptoPair with USDBTC-USD, ETH-USD
FXPair plus =XEURUSD=X, USDJPY=X
FuturesRoot plus =FGC=F, CL=F

Date ranges go back as far as the instrument's listing — often twenty years or more for large US stocks, much less for a recent crypto pair. A range shorter than about six months rarely produces enough trades to mean anything.

Reading the report

Read it in this order. It is designed to be read in this order:

  1. The verdict line. One sentence, in money, before any percentage.
  2. Worst drop. Before the return. If you would not have survived the drawdown, the return is fiction.
  3. The heatmap. Was it steady, or one lucky quarter?
  4. Trade count. Under about twenty trades, treat every statistic as noise.
  5. The code. Especially if the result is excellent.

The glossary on the how-it-works page maps each plain-language label to its formal name.

What it can't do

  • Intraday. Daily bars only. Anything depending on what happened between the open and the close cannot be tested here.
  • Multiple instruments in one run. One ticker per backtest. Pairs trading, rotation and portfolio strategies are not supported yet.
  • Shorting. Long-only for now.
  • Options, futures spreads, anything with legs. Single-instrument long positions only.
  • Live trading. Not a roadmap item. AlphaBack does not connect to a broker and does not hold funds.

Recipes

Working starting points. Copy one, change a number, run it, and see what the change cost you.

Trend following

Buy SPY when the 50-day average crosses above the
200-day. Sell when it crosses back below.

Mean reversion

Buy QQQ when RSI falls under 30. Sell when RSI rises
above 55, or after 20 trading days, whichever is first.

Breakout with a stop

Buy NVDA when it closes at a new 50-day high on volume
above its 20-day average. Use a 10% trailing stop.

Dip buying with a filter

Buy AAPL when it falls more than 3% in a day, but only
if it is still above its 200-day average. Sell after 10
trading days or at a 6% loss, whichever comes first.
Change one thing at a time. Run the recipe, then change a single number and run it again. The difference between the two is information. Changing four things at once and getting a better result tells you nothing about which change helped.

Pick a recipe.
Break it on purpose.

That is genuinely the fastest way to learn what any of this means.