<!-- My indicators | Himbit Markets Docs | https://docs.himbit.com/my-indicators -->

# My indicators

Besides the 91 built-in indicators, you can write your own. **My indicators** runs indicators written in Pine Script® v5/v6 syntax: paste a script you already have, import a `.pine` file or start from a template, and it draws on the chart next to the built-in ones. Himbit Markets reads the same syntax with its own engine; Pine Script® is a trademark of TradingView, Inc., and Himbit Markets is not affiliated with TradingView.

It is free for signed-in members, up to 30 indicators per account. They are saved to your Himbit ID and follow you to every device.

## Open My indicators

Open **Indicators** (in the ticker bar, **/** or **Ctrl + K**) and pick the **My indicators** tab, next to **Built-in**, **New** and **Favorites**. The line at the top reads *written in Pine Script® v5/v6 syntax*, with a counter such as **4 / 30** on the right.

Not signed in? You still see the tab, with **Sign in to write your own indicators** and a **Sign in** button, and the templates show **Sign in to use**. Nothing is kept in the browser for guests.

Once you are signed in, the tab has:

- **New indicator** and **Import .pine**;
- **Saved indicators**: each row shows the name, when you last edited it, **Rename** and **On chart: 1** while it runs, then **Add**, **Edit code** (pencil), **Duplicate**, **Export .pine** and **Delete**;
- **Templates**: **MA Cross**, **RSI Zones**, **Bollinger Bands**, **MACD Histogram** and the strategy **SMA Cross Strategy**, each with **Use**, which saves a copy you can change.

Each script carries a label: **Indicator**, **Strategy** or **Library**, read from its code. Chips above the list filter by type, each with its count: **All**, **Indicator**, **Strategy**, and **Library** once you have saved one. A library holds functions for other scripts: you can keep, edit, rename, export or delete it, but **Add** stays off, because a library can't run on its own and importing libraries isn't supported yet. A strategy runs on the chart like an indicator and opens the [Strategy Tester](#strategy-tester).

**Add** puts one more copy of the indicator on the chart and leaves the dialog open, so you can run the same script twice with different settings. Up to 10 of your indicators can run at the same time.

Times in a script (hour, day of week, the daily VWAP…) are in UTC, as on crypto exchanges. The tab says so at the bottom.

## The editor

**New indicator**, **Edit code** or **Use** opens the editor. On a computer it docks on the right of the chart; drag its left edge to make it wider. On a phone it opens full screen.

- At the top: **Open…** (your saved indicators and the templates), the indicator's name with a pencil to rename it, and **×** to close.
- **Add to chart** saves the script and runs it. Once it is on the chart the button reads **Update on chart** and applies your changes, keeping its settings. Shortcut: **Ctrl + Enter**.
- **Save** (**Ctrl + S**) keeps a new version each time the code has changed.
- **History** lists the last 10 versions with their date and line count. **Restore this version** brings an old one back as a new version, so nothing is lost.
- **Duplicate** saves a copy named "{name} (copy)", **Export .pine** downloads the file and **Delete** removes it after you confirm.

The code is checked about half a second after you stop typing. The bar under the code says **Compiled · Pine v6 · 4 outputs, 3 inputs** when all is well. When something is wrong it names the line, for example **Line 6** *Syntax error near '(': a bracket is not closed*; click **Line 6** to jump there. An error that only shows while the script runs reads *Runtime error · line N: … (bar K)*. Unknown names come with a suggestion when one is close: *'ta.rsii' does not exist. Did you mean 'ta.rsi'?*

**Import .pine** reads a `.pine` file of up to 64 KB. The imported script is saved but does not run until you press **Add**.

An indicator takes its name from the title in its code, the first text in `indicator()` or `strategy()`: `indicator("RSI Zones")` is saved as **RSI Zones**, and an imported file gets the script's title, not the file name. A script without a title is named **Pine 1**, **Pine 2** and so on. Indicators saved earlier under the old default name *My indicator* get their name from their code.

To rename one, click the name or the pencil next to it in the editor, or **Rename** in its row under **Saved indicators**. **Enter** saves the name and **Esc** cancels. A name you type stays even when you later change the title in the code. Clear the name and it follows the code again.

## On the chart

Your indicators sit in the chart's own indicator list, next to the built-in ones. They count in the **N indicators** row under the price line, and the **Indicators** counter in the top bar adds your saved indicators to the built-in ones: **5/93** means 5 indicators on the chart out of 91 built-in plus 2 of yours.

Each one gets a row like any built-in indicator: a coloured tick, its name and live values, then the eye to **Hide** / **Show** it, the gear for its settings, **×** to take it off the chart and **More** (…) with **Settings…**, **Edit code** (opens the editor) and **Remove {name}**. Taking an indicator off the chart keeps it saved under **My indicators**. If the script fails, the row shows *Error on line N*; click it to open the editor at that line.

Settings open in the same settings dock as the built-in indicators, with two tabs built from the script itself. **Inputs** lists every `input.*` with its title and default, such as **Length**, **Overbought** and **Oversold** in RSI Zones. **Style** has, for each output, **Visible**, **Colour** and **Width**. Changes redraw the indicator straight away, and **Reset to defaults** goes back to the script's values. On a phone the dock opens full width, as for the other indicators.

Everything else that works on indicators works on yours too: the eye that hides all indicators, the **Indicators** tab of the Objects panel, **Chart settings › Indicators**, and right-click › **Remove all indicators**, which takes them off the chart without deleting them.

Overlay indicators (`overlay = true`) draw on the price pane; the others get their own pane under it, as RSI or MACD do.

## Delete and undo

**Delete** asks for confirmation in the row itself. A deleted indicator is also taken off the chart, and a bar *"{name}" deleted* offers **Undo** for 10 seconds.

## Alerts on your indicators

Your indicators can raise alerts like the built-in ones. Click the bell on the indicator's row on the chart, or open **Alerts** and pick the indicator under **Alert me when**. Four kinds of alert are offered:

- **A line of the indicator**: pick one of its plots under **Plot**, then a **Condition** such as **Crosses above**, **Crosses below**, **Greater than** or a channel, the same list as for the built-in indicators. For example, price crossing above your EMA 20.
- **An `alertcondition()`**: each one in the script shows up by its title, with its message.
- **Any alert() call**: fires whenever the script calls `alert()`, with the message the script gives.
- **New label on the chart**: fires each time the script draws a new label with `label.new`. The notification reads the indicator's name, the label's text and the price, for example *My Signals · BUY · 90.27*. A script that only draws labels can use the bell too. Labels already on the chart when you reload the page do not fire again.

If an indicator has nothing to alert on (no plot, no `alertcondition()`, no `alert()` and no label), the form says so instead of showing an empty list.

When an alert is set, a small bell stays on the indicator's row. Alerts show as a pop-up and in the **History** tab of the Alerts panel.

These alerts only fire while the app is open and the indicator is on the chart, and the form says so. The script runs in your browser, so with the app closed nothing is checking it. Lock-screen alerts work for price and the built-in indicators, not for your own scripts.

## What the syntax supports

- **Declaration**: `indicator()` or `strategy()`, with title, short title, overlay, precision and the `max_lines_count`, `max_labels_count` and `max_boxes_count` limits.
- **Plots**: `plot`, `hline`, `fill`, `bgcolor`, `barcolor` (recolours the candles; not on Heikin Ashi or line charts), `plotshape`, `plotchar` and `plotarrow`. Up to 64 outputs per script.
- **Drawings**: `line`, `label`, `box`, `polyline`, `linefill` and `chart.point`, plus `table`. By default a script keeps its last 50 lines, labels or boxes; `max_lines_count` and the like raise that to 500 (100 for polylines). A table sits in a corner of the chart with a **×** to close it; a closed table leaves a small chip with the indicator's name, and a click on the chip brings it back.
- **Inputs**: `input.int`, `input.float`, `input.bool`, `input.string`, `input.color`, `input.source`, `input.timeframe`, `input.session`, `input.symbol`, `input.text_area`, `input.price`, `input.time` and `input.enum`. An input with options shows a list. A text or session input without options is a box you type into; the new value applies when you leave the box or press **Enter**. In Pine v6, `active = false` dims a setting in the settings dock, for example a length that only matters when another option is on.
- **Built-in functions**: more than 50 `ta.*` functions, including `sma`, `ema`, `rma`, `wma`, `hma`, `vwma`, `alma`, `rsi`, `macd`, `stoch`, `cci`, `mfi`, `atr`, `bb`, `kc`, `dmi`, `supertrend`, `sar`, `vwap`, `crossover` / `crossunder`, `highest` / `lowest`, `pivothigh` / `pivotlow`, `barssince`, `valuewhen` and `linreg`, plus `math.*`, `str.*` and `color.*`.
- **Your own types**: `type` with fields and `.new()`, `method` and `enum`.
- **Collections**: `array.*`, `map.*` and `matrix.*`, with `for … in` loops. One array, map or matrix holds up to 100,000 elements.
- **Language**: `var`, `varip`, `:=`, `if` / `else`, `?:`, `switch`, `for` and `while` loops, your own functions, tuples, history `x[n]`, `na` / `nz` / `fixnan`, `bar_index`, `barstate.*`, `timeframe.*` and `syminfo.ticker`. `varip` keeps what happens on each price update of the forming candle. `time(timeframe, session, timezone)` returns the bar's time only when the bar opens inside the session, such as `"0930-1600:23456"` (days 1 = Sunday to 7 = Saturday), read in the time zone you give, for example `"America/New_York"` or `"UTC+7"`; outside the session it returns `na`. That lets a script mark the New York, London, Tokyo or Sydney session.
- **Alerts**: `alertcondition()` and `alert()` feed the alerts described above.

### Strategies

A script that starts with `strategy(…)` places its orders on the chart. `strategy.entry`, `strategy.order`, `strategy.exit` (stop, limit and brackets), `strategy.close`, `strategy.close_all`, `strategy.cancel` and `strategy.cancel_all` work on one net position. A market order fills at the next candle's open, or at the close with `process_orders_on_close = true`; limit and stop orders fill when the candle reaches them. Initial capital, order size (fixed, cash or % of equity), pyramiding and commission come from `strategy()`.

Each fill is drawn on the chart as an arrow with the order's name and size: green for buys, red for sells, grey for exits, in the app's own colours. The script can read values such as `strategy.netprofit`, `strategy.closedtrades`, `strategy.position_size` or `strategy.max_drawdown`, for example to show them in a table. The full backtest report is in the [Strategy Tester](#strategy-tester).

### Higher and lower timeframes

`request.security` reads the chart's own symbol on a higher timeframe, for example a 15-minute EMA on a 1-minute chart. The timeframe is a fixed text such as `"15"`, `"60"`, `"240"`, `"D"` or `"W"`, and `lookahead` and `gaps` work as in Pine. Other symbols are not available in this version, and the editor says so.

`request.security_lower_tf` reads the chart's own symbol on a lower timeframe. For each chart bar it returns an array with the values of the smaller bars inside it, for example the 1-minute closes inside a 15-minute bar. The timeframe is a fixed text in minutes or more, such as `"1"` or `"5"`, and must not be higher than the chart's. The smaller bars are loaded once, about the last 10,000 of them (on 1 minute that is about 7 days); older chart bars get empty arrays. The bar that is still forming is refreshed about once a minute.

### Not supported yet

These stop with *'…' is not supported in this version yet*: `request.*` other than `request.security` on the same symbol, `ticker.*`, `session.*`, `log.*`, `library`, `import`, `plotcandle` and `plotbar`.

Limits that keep the chart fast: 64 KB per script, the last 5,000 bars, and 3 seconds per run. A script that takes longer stops with *The script took too long to run (more than 3 seconds)*.

Limits of `request.security_lower_tf`: the chart's own symbol only, about 10,000 smaller bars at most, and no seconds timeframes: a timeframe under 1 minute gives empty arrays.
