# 1.2	Example UDI code

It's possible to learn how to write UDIs just from these example files, without reading this document. The number at the start of each file, e.g. 01-udi-basic-sma.js, is the suggested order for working through the examples.

&#x20;

The code in the example files and this guide uses one convention, entirely optional. When the code wants to store a value for later use, across different calls to UDI.onCalculate(), it does so by storing the value in the UDI object – rather than using a global variable, for example – and it prefaces the name with $. For example, from the 04-udi-macd.js file:

&#x20;

UDI.$myFastMA = Liquid.ta.CreateMovingAverage(maType, {period: fastPeriod});

&#x20;

The $ has no special meaning in Javascript. The example code does this for two reasons: (a) to make clear what is a built-in function or property of the UDI object versus its own private data which the code is storing, and (b) to avoid any possible collision between names of the private variables and names of built-in UDI properties or functions.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://liquid-charts.gitbook.io/liquid-charts-api-docs/liquid-charts-pro-scripts-documentation/liquid-charts-pro-user-defined-indicators/introduction/1.2-example-udi-code.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
