# Limits and troubleshooting

Source: https://tapehawk.com/docs/custom-indicators/limits-and-troubleshooting

> What TapeHawk refuses in an indicator script, the common error messages and what they mean, why a script can draw nothing, and what to do when your indicators stop running.

## Reading a message

The indicator editor shows the server's own messages: what is wrong, the position (<code>line 3, col 14</code>), and
often a hint about what to write instead. The code a message quotes between backticks is your own.

The checker stops at the first problem it finds, so fixing one can reveal the next.

## Common errors

| The message contains                                              | What it means                                                                                                                                                                                                                                                                      | What to do                                                                                                        |
| ----------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| `` `x` is not declared ``                                         | A typo, a name used above the line that declares it, a plot name used as a value, or a list word outside a comparison with its own input                                                                                                                                           | Check the spelling and the order. To use what a plot draws, name the value first and plot the name                |
| `` there is no function `f` ``                                    | There is no built-in function `f`                                                                                                                                                                                                                                                  | See [Functions](https://tapehawk.com/docs/custom-indicators/language-reference#functions)                                             |
| `` `f` needs 2 parameters, got 1 ``                               | `f` takes a different number of arguments                                                                                                                                                                                                                                          | See the function's signature                                                                                      |
| `is outside the range 1..4000`                                    | A window length is outside 1 to 4,000                                                                                                                                                                                                                                              | Use a smaller length, or a smaller `max` on the input                                                             |
| `indented with a tab`                                             | A line is indented with a tab                                                                                                                                                                                                                                                      | Indent with spaces                                                                                                |
| `this indent level does not match any open block`                 | A line's indentation does not line up with the `if` it belongs to                                                                                                                                                                                                                  | Indent the body of each `if` or `else` by the same amount                                                         |
| `comparisons cannot be chained`                                   | A chained comparison, `a < b < c`                                                                                                                                                                                                                                                  | Write `a < b and b < c`                                                                                           |
| `` `x` is already declared at line ``                             | `x` is declared twice                                                                                                                                                                                                                                                              | Rename one of them                                                                                                |
| `` `x` is a built-in function `` or `is a built-in source`        | `x` is the name of a built-in function or of a source — `t`, `day` and `vol` are sources too                                                                                                                                                                                       | Choose another name                                                                                               |
| `` `x` is a language keyword ``                                   | A name you declared is one of `var` `if` `else` `and` `or` `not`                                                                                                                                                                                                                   | Choose another name                                                                                               |
| `` `x` is a keyword, not a value ``                               | A keyword where a value belongs — usually one side of `and`, `or` or a comparison is missing                                                                                                                                                                                       | Complete the expression                                                                                           |
| `` cannot infer the domain of `p` ``                              | The checker cannot tell what kind of number plot `p` holds                                                                                                                                                                                                                         | Add `, domain price`, `count`, `osc100` or `zero` — see [`plot`](https://tapehawk.com/docs/custom-indicators/language-reference#plot) |
| `the definition draws nothing, marks nothing, and alerts nothing` | The script has no `plot` or `mark`                                                                                                                                                                                                                                                 | Add a `plot`                                                                                                      |
| `a string cannot be used in an expression`                        | Text in quotes inside an expression                                                                                                                                                                                                                                                | Use a number, or move the text to a label                                                                         |
| `unexpected character`                                            | A character the language has no use for, such as `%`, `&`, `^` or `?`                                                                                                                                                                                                              | See [Operators](https://tapehawk.com/docs/custom-indicators/language-reference#operators)                                             |
| `cannot read … here`                                              | A word or symbol in a place where it cannot go                                                                                                                                                                                                                                     | Check the line against the syntax of what it declares                                                             |
| `` `x` does not exist yet to reassign ``                          | `:=` on a name that was not declared with `var` or inside the statements                                                                                                                                                                                                           | Declare it with `var x = …` above                                                                                 |
| `is not a statement`                                              | An `input`, `plot` or `alert` inside an `if` — the message names which                                                                                                                                                                                                             | Move it out of the `if`, above the statements for an `input`                                                      |
| `` `input` must come above every statement ``                     | An `input` below the first `var`, `if` or `:=`                                                                                                                                                                                                                                     | Move every `input` above the statements                                                                           |
| `` `mark m` needs `@print`, `@book` or `@cell` ``                 | A `mark` on the bar clock                                                                                                                                                                                                                                                          | Marks need an [event clock](https://tapehawk.com/docs/custom-indicators/language-reference#clocks)                                    |
| `` `f` can only be read under `@print` ``                         | A trade-clock function in a script on another clock                                                                                                                                                                                                                                | Add `@print` at the top, or use a bar-clock function                                                              |
| `name is … characters long, limit is 40`                          | A name longer than 40 characters                                                                                                                                                                                                                                                   | Shorten it                                                                                                        |
| `compiles, but a condition cannot carry an alert`                 | A script on the trade, footprint-column or order-book clock declares an `alert`, which only a candle script may. The hint says what the script can do instead: on the trade or footprint-column clock the line can become a `mark`; an order-book signal cannot carry an alert yet | Change it to a `mark`, or delete the line — see [`alert`](https://tapehawk.com/docs/custom-indicators/language-reference#alert)       |
| `bars of warm-up and the window tops out at 1000`                 | The script needs more than 1,000 bars of warm-up at the largest values its inputs may take                                                                                                                                                                                         | Lower the `max` of inputs used as lengths, or use shorter windows                                                 |
| `fuel per run` or `fuel per event`                                | A bar-clock script asks for more work over the candles it runs on than one script may do, or an event-clock script for more work on a single trade or order-book frame. A footprint-column script with a `mark` is checked over the two columns each of its checks runs            | Shorten windows, draw fewer lines, or read a narrower range of the order book                                     |
| `indicators, limit is`                                            | Your account holds as many indicators as it may                                                                                                                                                                                                                                    | Delete one you no longer use, then save again                                                                     |
| `total indicator cost`                                            | Saving would push the work of all your indicators together past what an account may use                                                                                                                                                                                            | Shorten windows or delete an old indicator. Saving a cheaper version of a script is always allowed                |

## Limits

A script is refused, with a message, when it goes past any of these:

| What                                   | Limit                                                 |
| -------------------------------------- | ----------------------------------------------------- |
| The script                             | 65,536 bytes                                          |
| Indicator or value name                | 40 characters                                         |
| Window length                          | 1 to 4,000                                            |
| Warm-up of a bar-clock script          | 1,000 bars, at the largest values its inputs may take |
| Choices in a list input                | 20                                                    |
| Array slots, all arrays together       | 4,000                                                 |
| `mark` declarations in a script        | 8                                                     |
| A mark's `cap`                         | 100 a minute                                          |
| A mark's `title` or `msg`              | 512 bytes and 8 placeholders                          |
| Nesting of expressions and `if` bodies | 64 deep                                               |

Some limits have no fixed number you can plan around, and are set by TapeHawk:

* **The work a script may do** in one run: over the candles it is given on the bar clock, on one trade or order-book
  update, or over the footprint columns a check covers. Long windows, many lines and wide order-book ranges cost more.
* **The work all your indicators may do together**, and **how many indicators an account holds.** Editing an existing
  indicator into a cheaper one is always allowed, even when the account is over.
* **The size of a script.** A very long script is refused when it is checked or saved.

## A script that draws nothing

Go through these in order:

1. **Does it compile?** When the editor lists an error, the preview keeps showing the last version that compiled, and a
   script with an error cannot be saved.
2. **Is it on the right panel?** A script with `@print` or `@book` at the top draws on heatmap panels only — a candles
   or footprint panel's menu lists it with a note instead. A `@book` line starts empty and fills in as the book updates,
   and a `@cell` script marks only columns that have closed, so the newest bar has none yet — see
   [Your indicator on a chart](https://tapehawk.com/docs/custom-indicators/overview#your-indicator-on-a-chart).
3. **Is the warm-up longer than the history?** A line is blank until its windows have filled, at the settings in use — a
   200-bar average over the last 150 bars on screen draws nothing. Scroll back to load more bars, or shorten the window.
   The warm-up the editor reports is counted at the inputs' defaults, so a higher setting on a panel needs more bars.
4. **Are there too many bars on screen?** A script can read only so many bars at once — fewer the more lines, windows,
   sources and array slots it has. Past that its row in the info bar shows a ⚠ asking you to scroll forward or zoom in.
5. **Does it read order flow?** `delta`, `cvd` and `vol` need order flow on the panel.
   * A saved indicator that reads any of them loads order flow on the panel it is added to, whatever the domains of its lines.
   * The editor's preview loads order flow for the draft too.
   * Order flow exists only on the timeframes and candle shapes where order-flow indicators draw — see
     [Where an indicator can be drawn](https://tapehawk.com/docs/indicators#where-an-indicator-can-be-drawn) — and on a live-only symbol it
     reaches back only about half an hour — see
     [Recorded symbols and live-only symbols](https://tapehawk.com/docs/chart/symbols-and-venues#recorded-symbols-and-live-only-symbols).
6. **Is every value `nan`?** A comparison with `nan` is false, and a value built on its own `prev` that starts from `nan`
   stays `nan` — `select(close > prev(top), close, prev(top))` never gets going, while `max(close, prev(top))` does. Plot
   the intermediate values one at a time to find where the numbers disappear.
7. **Did the script stop?** An array index outside the array, or `decay` given `nan`, stops the script as it runs and
   nothing is drawn. Guard the index or the value with `if`.

A saved indicator whose script no longer compiles — after a change in the language — is listed in the indicator menu with
a note to open the editor and fix it.

## When your indicators are not running

A banner at the top of the editor says when TapeHawk is not running the alerts on the indicators you wrote:

* Alerts on user-written indicators are temporarily switched OFF by an operator, so they do not notify. Your scripts are stored untouched.
* Under heavy load, a banner says how many alerts on your indicators are temporarily not being evaluated — one for each
  rule on each market and timeframe it watches. It clears by itself when the load drops.

Your scripts are not changed in either case, but while a banner shows, those rules are not evaluated and send no
notifications — see
[Custom indicators](https://tapehawk.com/docs/custom-indicators/overview#alerts).
