# Build logic with the graph editor

> Create graphs, connect nodes, save them and assign them to strategies.

Source: https://quantraider.com/docs/graph-editor

The graph editor lets you describe trading logic as nodes connected by wires. A graph can find setups, compute values and place a trade entry. Backtests and live automations run the graph for you.

> Not financial advice. Trading involves risk of loss.

## Open the graph library

Choose **Graph editor** in the sidebar, or open the **Graph** tab of a strategy. With no graph open, the page is called **Graph library**. It has two tabs: **My graphs** and **Public**. **Public** lists the built-in QuantRaider indicators by category and the graphs other users have published, with their author, parameters and outputs. You cannot change a public graph, but you can press **Create my own copy** to get an editable graph of your own, or add it to one of your graphs from the node library's **Published** tab. The selected tab is part of the page address, so a link keeps it.

- Use **Search graphs** to filter by name or description.
- Graphs are grouped by type. Each row shows the name and description. A published graph also shows who published it.
- The buttons on a row open the graph, edit its name and description (**Edit**), publish or unpublish it, and delete it.

## Create a graph

1. Choose **Create graph**.
2. Choose a **Graph type**.
   - **Trading graph**: trading logic that can contain execution nodes, such as a trade entry.
   - **Indicator graph**: a reusable indicator with configurable parameters and sockets. Execution nodes are not allowed.
3. Enter a **Graph name** and, if you like, a **Description**.
4. Choose **Create graph**.

The graph opens in the editor.

## Build the logic

The editor has a canvas in the middle, a toolbar on top and the **Node library** on the right.

### Add nodes

- Drag a node from the **Node library** onto the canvas, or click it to add it.
- Or right-click an empty part of the canvas and pick a category, then a node.
- Use the search box in the library to find a node. The tabs **Nodes**, **My graphs** and **Published** switch between built-in nodes and reusable graphs. The built-in nodes are listed in the [Node reference](/docs/graph-nodes).

### Connect nodes

Each node has sockets: inputs on one side, outputs on the other. Sockets have a data type: number, boolean (true or false) or a list of numbers.

1. Drag from an output socket to an input socket. You can also click the first socket and then the second.
2. To remove a wire, click it to select it and press Delete. Escape deselects the wire, and also cancels a wire you have started but not finished.

### Edit nodes

Right-click a node for **Copy**, **Paste**, **Duplicate** (Ctrl D), **Delete** (Del) and **Group into custom node**. A custom node packs several nodes into one. Select it and choose **Ungroup** (Ctrl U) to take it apart.

### Toolbar

| Control | What it does |
|---|---|
| Undo, Redo | Step back and forward through your changes. |
| Clean up | Arranges the nodes automatically. |
| Fit graph to view | Zooms to show every node. |
| Import graph from JSON, Export graph as JSON | Move a graph in and out as a file. |
| Assistant | Opens the [graph assistant](/docs/graph-assistant), when it is available. |
| Save | Saves the graph. A dot on the button means there are unsaved changes. |

A message tells you whether saving worked. Save before you leave the page.

## Use a graph in a strategy

A graph does nothing for a strategy until you assign it.

1. Open the strategy and choose its **Edit** tab.
2. Under **Graphs**, choose **Assign graphs** and tick the graph.

Then:

- In the **Backtest** tab, choose **Logic graph** in the left toolbar to pick the graph. While replaying, **Next trade** advances until the graph triggers a trade. See [Manual backtesting](/docs/manual-backtesting).
- In the **Auto backtest** tab, choose the graph under **Graph**. See [Auto backtest](/docs/auto-backtest).
- In live automations, you pick a saved graph for each automation. See [Live chart, orders and automations](/docs/live-trading-and-automations).

After you change a graph, use **Sync graph items** next to it on the Edit tab to refresh the link.

## Reuse and share graphs

- In the Node library, **My graphs** lists your graphs and **Published** lists graphs other users have published, and at the top the **QuantRaider built-in** indicators such as RSI, MACD or Bollinger Bands (see [Built-in indicators](/docs/built-in-indicators)). Click or drag one to add it to your canvas as a copy. Later changes to the original do not change your copy.
- **Publish** makes a graph visible to other signed-in users. They can see and copy its full node logic, settings and description. Your profile username is shown as the author. **Unpublish** hides it again. Copies that others already made are kept.
- Deleting a graph removes it, its assignments and its node mappings in every strategy. This cannot be undone. You are asked to confirm.

## Limits

An indicator graph cannot contain a trade entry. If you try, the app says: **Indicator graphs cannot contain execution nodes.**
