Built-in algorithms
Every algorithm that ships with Neurotrader, with its trading rule and a table of its parameters, defaults and limits.
Neurotrader ships with a set of algorithms that are ready to add to a simulation. Use this page to look up what each one does and what its parameters accept. The app shows the same information in the details pane of the Algorithms page.
Baselines
Every trading algorithm on this page is a baseline: a simple, well-known rule with nothing hidden in it. Baselines exist to be measured against. A strategy of your own is only interesting if it does better than they do, on the same data, after fees. The app lists them under the category Simple baseline.
Six of them are plain yardsticks that use no indicator at all:
| Yardstick | Question |
|---|---|
| Cash | Did the strategy do better than doing nothing? |
| Buy and Hold | Did it do better than simply owning the asset? |
| Dollar-Cost Averaging | Did it do better than buying a fixed amount regularly? |
| Constant Mix | Did it do better than a fixed split between the asset and cash? |
| Equal Weight | Did it do better than holding every instrument equally? |
| Random | Did it do better than chance? |
The others follow indicator rules. Two more built-in entries, Group and Remote, are not strategies. They hold or reach other algorithms.
None of these algorithms is a recommendation, and a good backtest of any of them is not a promise.
Conventions
- Instruments. Unless its section says otherwise, an algorithm trades one instrument.
- Order sizes. An algorithm that buys with the whole cash balance holds back 1% of it, because the order is sized at one candle's close and fills at the next candle's open.
- Committed Fraction. Several algorithms have a
committedparameter: the fraction of the free cash balance that one entry uses. - Schedule. Several algorithms act on a schedule. A schedule is
day,weekormonth, meaning the first candle of each calendar day, week or month, or "every N candles", a count from 1 upward. The default ismonth. A calendar schedule means the same on hourly and on daily candles. - Bounds. "above 0" excludes the value itself, and "0 to 1" includes both ends unless the table says otherwise.
Cash
Holds the starting balance and never trades. It is the floor every other strategy is measured against: its return is zero, and its net worth line is flat. Cash takes no parameters.
Buy and Hold
Buys the asset with the whole cash balance on the first candle and holds it to the end of the run. If the first order is rejected, it tries again on the next candle. It trades exactly one instrument and takes no parameters.
Dollar-Cost Averaging
Buys a fixed amount of the asset at market on a schedule and never sells. A contribution that the free balance cannot cover in full is skipped, not reduced, so a fixed starting balance pays for a fixed number of contributions.
| Parameter | Key | Type | Default | Bounds |
|---|---|---|---|---|
| Contribution | notional | Number | 100 | Above 0 |
| Schedule | schedule | Schedule | month | See Conventions |
The contribution is an amount of the simulation's primary quote asset. Both parameters are required.
Constant Mix
Holds a target fraction of the net worth in the asset and the rest in cash. It trades back to the target on a schedule, when the weight has drifted by more than a band, or on whichever happens first.
| Parameter | Key | Type | Default | Bounds |
|---|---|---|---|---|
| Target Weight | target | Number | 0.6 | Above 0, below 1 |
| Rebalance Schedule | schedule | Schedule, or empty | month | See Conventions |
| Drift Band | band | Number, or empty | Empty | Above 0 |
The target is required. An empty schedule means the band alone decides, and an empty band means the schedule alone decides. The band is a fraction: 0.05 is five percentage points. A band narrower than a typical candle's move trades on nearly every candle and loses to fees.
Equal Weight
Holds every instrument it reads at the same share of the net worth, and rebalances on a schedule, on a drift band, or on whichever happens first. It is the baseline for several instruments: it needs two or more, all quoted in the same asset.
| Parameter | Key | Type | Default | Bounds |
|---|---|---|---|---|
| Invested Fraction | invested | Number | 1 | Above 0, up to 1 |
| Rebalance Schedule | schedule | Schedule, or empty | month | See Conventions |
| Drift Band | band | Number, or empty | Empty | Above 0 |
The invested fraction is the share of the net worth held in instruments at all, and it is required. The rest stays in cash. A rebalance sells and buys in one step, and the buys can only spend the cash that is free at that moment, so a fully invested portfolio can take two rebalances to settle.
Random
Makes random buy and sell decisions. On each candle on which a trade is affordable, it trades with the given probability, and each entry carries a take profit and a stop loss. It holds one such position at a time. The choices come from the run's seed, so the same run repeated makes the same trades. The app also lists it under Stochastic.
| Parameter | Key | Type | Default | Bounds |
|---|---|---|---|---|
| Trade Probability | trade_probability | Number | 0.5 | 0 to 1 |
| Take Profit (%) | take_profit | Number | 0.3 | Above 0, below 100 |
| Stop Loss (%) | stop_loss | Number | 0.3 | Above 0, below 100 |
The trade probability is required. The take profit and the stop loss are distances from the entry price, in percent. The stop loss also sets how much of the account one trade needs.
SMA Crossover
Buys with the cash balance when a fast simple moving average crosses above a slow one, and sells the position when it crosses back below.
| Parameter | Key | Type | Default | Bounds |
|---|---|---|---|---|
| Fast Period | fast_period | Whole number | 9 | 1 or more |
| Slow Period | slow_period | Whole number | 21 | 2 or more |
Both periods are in candles and both are required. The slow period must be longer than the fast one.
SMA Long/Short
Long while a fast simple moving average is above a slow one and short while it is below, on a margin account at a chosen leverage. The signal is the same as SMA Crossover. What it adds is the short side and the loan behind it. It closes its position on a margin call, and it does not trade on an account that does not offer its leverage, which includes every spot account. See Margin and leverage.
| Parameter | Key | Type | Default | Bounds |
|---|---|---|---|---|
| Fast Period | fast_period | Whole number | 9 | 1 or more |
| Slow Period | slow_period | Whole number | 21 | 2 or more |
| Leverage | leverage | Number | 2 | 1 or more |
| Minimum Margin Level | min_margin_level | Number | 1.5 | 1 or more |
All four are required. The leverage must be a level the simulation offers. No new position is opened while the account's margin level is below the minimum. Closing is never held back.
MACD Crossover
Buys when the MACD line crosses up through its signal line and sells when it crosses back down. This is the same idea as SMA Crossover, a fast average overtaking a slow one, built from exponential averages.
| Parameter | Key | Type | Default | Bounds |
|---|---|---|---|---|
| Fast Period | fast_period | Whole number | 12 | 1 or more |
| Slow Period | slow_period | Whole number | 26 | 2 or more |
| Signal Period | signal_period | Whole number | 9 | 1 or more |
| Committed Fraction | committed | Number | 1 | Above 0, up to 1 |
All four are required. The slow period must be longer than the fast one.
RSI Threshold
Buys when the relative strength index crosses up through a lower threshold and sells the position when it crosses down through an upper one. It acts on the crossing, not on the level: an index that stays below the threshold for weeks produces one buy. Compare it with Bollinger Band Reversion, whose levels move with volatility.
| Parameter | Key | Type | Default | Bounds |
|---|---|---|---|---|
| Period | period | Whole number | 14 | 2 or more |
| Oversold Threshold | lower | Number | 30 | Above 0, below 100 |
| Overbought Threshold | upper | Number | 70 | Above 0, below 100 |
| Committed Fraction | committed | Number | 1 | Above 0, up to 1 |
All four are required. The app also lists it under Technical analysis.
Bollinger Band Reversion
Buys when the price closes below the lower Bollinger band, and closes the position when the price returns to the middle band or, by choice, to the upper one. The level it trades against widens and narrows with volatility.
| Parameter | Key | Type | Default | Bounds |
|---|---|---|---|---|
| Period | period | Whole number | 20 | 2 or more |
| Band Width | multiplier | Number | 2 | Above 0 |
| Exit | exit | Choice | middle | middle or upper |
| Committed Fraction | committed | Number | 1 | Above 0, up to 1 |
All four are required. The band width is the number of standard deviations between the middle band and the outer bands.
Time-Series Momentum
Holds the asset while its return over the last N candles is positive, and holds cash otherwise. It looks again only on its schedule. It has two states and no sizes in between: already holding is not a signal to buy more.
| Parameter | Key | Type | Default | Bounds |
|---|---|---|---|---|
| Lookback | lookback | Whole number | 12 | 1 or more |
| Re-evaluation Schedule | schedule | Schedule | month | See Conventions |
Both are required. Looking again on every candle is a different strategy with far more trades.
Donchian Breakout
Places a stop order at the highest high of the last N candles and buys when the price breaks through it. It leaves on a break of the lowest low of the last M candles, again with a stop order. It is the baseline that works with waiting orders: its journal shows stops being placed, moved and triggered.
| Parameter | Key | Type | Default | Bounds |
|---|---|---|---|---|
| Entry Channel | entry_period | Whole number | 20 | 2 or more |
| Exit Channel | exit_period | Whole number | 10 | 2 or more |
| Committed Fraction | committed | Number | 1 | Above 0, up to 1 |
All three are required. The exit channel is shorter than the entry channel by convention, so a position is left faster than it is entered.
ATR Trailing Stop
Enters exactly as Donchian Breakout does, and exits with a stop that follows the price upward at a distance of a multiple of the average true range. The stop moves up and never down. Run it against Donchian Breakout to compare two exits from the same entry.
| Parameter | Key | Type | Default | Bounds |
|---|---|---|---|---|
| Entry Channel | entry_period | Whole number | 20 | 2 or more |
| ATR Period | atr_period | Whole number | 14 | 1 or more |
| Stop Multiple | multiple | Number | 3 | Above 0 |
| Ratchet Threshold | ratchet | Number | 0.5 | 0 or more |
| Committed Fraction | committed | Number | 1 | Above 0, up to 1 |
All five are required. A wider stop multiple survives more noise and gives back more profit. The ratchet threshold is how far the stop must improve, in average ranges, before it is moved. Moving a stop is a cancel and a new order, so at 0 the stop is replaced on nearly every candle.
Group
Holds several algorithms that trade one account together. You do not add Group yourself: the app builds it when you put several algorithms on one account. See Algorithm groups.
Remote
Connects a simulation to a program of your own that the engine calls on every step. See Remote algorithms.
| Parameter | Key | Type | Default | Bounds |
|---|---|---|---|---|
| URL | url | Text | None | An http, https, ws or wss address |
| Encoding | encoding | Choice | json | json or msgpack |
| Protocol version | version | Whole number | Empty | 1 or more |
The URL is required. With http or https the engine sends one request per
call. With ws or wss it keeps one connection for the run. Leave the
protocol version empty to let the engine and your program agree on one.
Related
- Algorithms: entries, instances and parameters
- Algorithm setup
- Algorithm comparison: a strategy against a yardstick
- Plugin authoring: algorithms of your own
list_algorithmsin the API reference