# Scripting

## Agena indicator <a href="#agena-indicator" id="agena-indicator"></a>

[Agena indicator Help Guide](https://indicators.agenatrader.com/) provides extensive information about indicators integrated in AgenaTrader:

* Description of indicators and oscillators;
* Meaning of parameters;
* Use and interpretation of signals;
* Syntax and code examples;
* References.

## Scripting

### Scripting environment <a href="#scripting-environment" id="scripting-environment"></a>

AgenaTrader's programming environment is comparable to Visual Studio. It enables you to:

1. navigate the programming workspace using toolbars,
2. handle multiple components at the same time via the editor (top tab bar),
3. use the IntelliSense® functionality,
4. view a list of errors at the bottom of the screen.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlpxlqigsDWQt-9Uk-%252Fscripting1.png%3Falt%3Dmedia%26token%3D548a2c98-6964-4e30-983f-0ae3dd767327&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=a5c09429&#x26;sv=1" alt=""><figcaption></figcaption></figure>

### Scripting toolbar <a href="#scripting_toolbar" id="scripting_toolbar"></a>

| Icon                                                                                                                                                                                                                                                                                                                                                                                                                       | Function                                                              |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| ![Scrp](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlq03NzUNjuDA3wIlj%252Fscrp.png%3Falt%3Dmedia%26token%3D087eb362-73e3-4f95-b58b-9458eb694423\&width=300\&dpr=4\&quality=100\&sign=ae338bf5\&sv=1)                                                     | Loads existing self-programmed indicators/strategies to the workspace |
| ![Scrp1](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlq6whcIuzLGbQtaz5%252Fscrp1.png%3Falt%3Dmedia%26token%3De1b59d2b-2cd2-4505-be14-092fa52ffab2\&width=300\&dpr=4\&quality=100\&sign=f06bacdd\&sv=1)                                                   | Saves source code changes                                             |
| ![Scrp2](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlqABqSCIsdTi9q-Hg%252Fscrp2.png%3Falt%3Dmedia%26token%3D29eb5648-059f-48e7-9226-0340f7f48386\&width=300\&dpr=4\&quality=100\&sign=f2690c37\&sv=1)                                                   | Cuts marked source code                                               |
| ![Scrp3](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlqDMkQexNe3vcT_wA%252Fscrp3.png%3Falt%3Dmedia%26token%3D078152cc-feea-4c11-920d-dcd91dd3964a\&width=300\&dpr=4\&quality=100\&sign=51ed8104\&sv=1)                                                   | Copies marked source code                                             |
| <img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlqGK4ZK36bD6mZnDL%252Fscrp4.png%3Falt%3Dmedia%26token%3Dc19a52bf-e597-4c21-8d65-79722ff6ccf8&#x26;width=300&#x26;dpr=4&#x26;quality=100&#x26;sign=6d07b151&#x26;sv=1" alt="" data-size="original"> | Pastes copied / cut source code                                       |
| ![Scrp5](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlqKqBt8NubsI1Kbkc%252Fscrp5.png%3Falt%3Dmedia%26token%3Dec5c2635-145a-477a-bf3f-7e6c6c1d14ed\&width=300\&dpr=4\&quality=100\&sign=609cad35\&sv=1)                                                   | Enables comments on marked source code parts                          |
| ![Scrp6](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlqOlD-0kij_4D-is9%252Fscrp6.png%3Falt%3Dmedia%26token%3D6c68b0a3-3cfb-4c8a-b543-9b70758b7b3e\&width=300\&dpr=4\&quality=100\&sign=a5a957ee\&sv=1)                                                   | Uncomments the selected lines                                         |
| ![Scrp7](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlqRxihQl1b9w0R0I7%252Fscrp7.png%3Falt%3Dmedia%26token%3Dc7559894-1b36-4707-a95a-3f692e1a229c\&width=300\&dpr=4\&quality=100\&sign=73d785ca\&sv=1)                                                   | Cancels previous action(s)                                            |
| ![Scrp8](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlqVklLPVISSLCuAjd%252Fscrp8.png%3Falt%3Dmedia%26token%3D17ef6c72-05cf-4634-9bf2-76eecbe2a264\&width=300\&dpr=4\&quality=100\&sign=fe1b9287\&sv=1)                                                   | Repeats cancelled action(s)                                           |
| ![Scrp9](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlqZFOTEYlEWF84sf7%252Fscrp9.png%3Falt%3Dmedia%26token%3D83f8725a-a35a-4461-a5ad-03bea5ecc377\&width=300\&dpr=4\&quality=100\&sign=6056c75d\&sv=1)                                                   | Opens output window                                                   |
| ![Scrp10](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlqbrfqfC9-r7-yzOB%252Fscrp10.png%3Falt%3Dmedia%26token%3D7066c2fa-2b7c-48d3-93e6-1455a13dadc1\&width=300\&dpr=4\&quality=100\&sign=95f196e4\&sv=1)                                                 | Opens reference popup                                                 |
| ![Scrp11](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlqf8B3tT6z1PeOX7M%252Fscrp11.png%3Falt%3Dmedia%26token%3Db6b6a67e-6844-4309-89f4-e638b2cf645e\&width=300\&dpr=4\&quality=100\&sign=373e0a0a\&sv=1)                                                 | Compiles sources                                                      |
| ![Scrp12](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlqjrsOTxbsfvbT6UK%252Fscrp12.png%3Falt%3Dmedia%26token%3D42c6e355-1a4d-4462-9aa5-b8f99e0f77e1\&width=300\&dpr=4\&quality=100\&sign=ef44149\&sv=1)                                                  | Searches for a text within source code                                |
| ![Scrp13](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlqo3oWOgOKGAA1fnz%252Fscrp13.png%3Falt%3Dmedia%26token%3D22686626-8671-4421-ad1f-bcbdec439085\&width=300\&dpr=4\&quality=100\&sign=7a169f30\&sv=1)                                                 | Find/Replace                                                          |
| ![Scrp14](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlqriX1AtOOYf8GIbu%252Fscrp14.png%3Falt%3Dmedia%26token%3D1f1b2a3d-2e27-4da0-828b-206f53cc8382\&width=300\&dpr=4\&quality=100\&sign=98802149\&sv=1)                                                 | Opens list of errors                                                  |
| ![Scrp15](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlqwaIw9d4kcZMAwgj%252Fscrp15.png%3Falt%3Dmedia%26token%3D934fb70b-6593-48cd-bd83-db7b5dc25e50\&width=300\&dpr=4\&quality=100\&sign=8257564\&sv=1)                                                  | Deletes file                                                          |

### Visual Studio <a href="#visual_studio" id="visual_studio"></a>

Microsoft provides a complimentary version known as **Visual Studio Community Edition**, which is highly suitable for developing AgenaScript code.

Download: [**Latest Version of Visual Studio**](https://visualstudio.microsoft.com/downloads/) Download: [**Older Versions of Visual Studio**](https://visualstudio.microsoft.com/vs/older-downloads/)

Supported Versions: • **Windows 10:** VS2017, VS2019, and VS2022 (latest builds/updates)

• **Windows 11:** VS2022 only (latest builds/updates)

• Please note that VS2015 and older are not supported by Microsoft anymore hence why we will not support either

This article was created by [http://script-trading.com.](http://script-trading.com/)

### AgenaTrader and Visual Studio <a href="#agenatrader_and_visual_studio" id="agenatrader_and_visual_studio"></a>

AgenaTrader provides its proprietary script editor, which is utilized for AgenaScript development.

![](https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlr8y65OnNVuoXI71Z%252FMyIndicator.jpg%3Falt%3Dmedia%26token%3Dc6564143-39ec-4429-9026-0ebd1c405ce0\&width=768\&dpr=4\&quality=100\&sign=802a73ed\&sv=1)

This editor serves as an efficient tool for making swift adjustments to a few lines of code or reviewing AgenaScript. For most other purposes, it is crucial to use Microsoft's Visual Studio development environment. Visual Studio offers a comprehensive and dependable solution, proving its efficacy across multiple facets of software development, including AgenaScript and C#

The most important advantages are:

* Debugging
* Code Completion
* Syntax checking

In addition, there is a multitude of further features that make developing easier for you.

You can download the free “Visual Studio Community” edition at <https://www.visualstudio.com/downloads>.&#x20;

{% hint style="info" %}
Please note that the download and the installation of the software take about 60 minutes!
{% endhint %}

As of AgenaTrader 2.0, it is mandatory to utilize "Visual Studio Community 2017" or later versions, due to the implementation of .NET version 4.6. Please refer to the list of compatible Visual Studio versions provided above.

Once you have successfully installed Visual Studio, you can link it to AgenaTrader using the Global Configuration setting shown below. From now on, all AgenaScript files will automatically be opened with Visual Studio, and the debugger will also automatically be linked to AgenaTrader.

Global Configuration setting for Visual Studio

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlrF6EWTAzZUud1xfC%252Fconfiguration.png%3Falt%3Dmedia%26token%3Da57af74c-c7a2-4ef7-a020-4ab0188ae521&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=af849f07&#x26;sv=1" alt=""><figcaption></figcaption></figure>

You can now conveniently develop, test and debug your AgenaScripts in Visual Studio.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlrJOS3Ko9B8kCUuZg%252FMyIndicatorVS.jpg%3Falt%3Dmedia%26token%3D54aaf414-179d-436a-ab8f-22a572f03cc9&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=7a36c314&#x26;sv=1" alt=""><figcaption></figcaption></figure>

This article was created by [http://script-trading.com.](http://script-trading.com/)

## <img src="https://2105664868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSb9KiaeLmZhUGHJdWN19%2Fuploads%2F5pazWNKBRFDCk1PqA1bR%2FImg_ScriptIndicator.png?alt=media&#x26;token=7bdfc2e8-c3f9-4811-8e88-b5afc05864cf" alt="" data-size="line"> Programming of indicators <a href="#scripting__programming_of_indicators" id="scripting__programming_of_indicators"></a>

Select the **Strategy Handlings-> Scripting** and then **Indicator -> New** or **Edit** menu items to program new indicators or make changes to existing indicators.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlrSByAHcM-QxB9hXB%252FScripting.png%3Falt%3Dmedia%26token%3D7a8d97b0-990b-4f4c-9d8d-f8621d8bfe1e&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=a0de85d5&#x26;sv=1" alt=""><figcaption></figcaption></figure>

### Editing indicators <a href="#editing" id="editing"></a>

Should you wish to change/modify an existing indicator, select the **Edit** menu item to open the following Indicators dialog window:

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlrVlLLmRDRWW6M6u3%252FEdit%2520indicators.PNG%3Falt%3Dmedia%26token%3D616abb32-2b83-4737-ac60-b0ef6be90a90&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=cc3309e5&#x26;sv=1" alt=""><figcaption></figcaption></figure>

*The buttons inside this window have the following functions:*

* Click the **Edit** button or double-click on the entry to open the scripting window for the selected indicator.
* Click the **Delete** button to remove the selected indicator.
* Click the **Compile** button to compile all indicators, conditions, strategies and alert handlers. If you delete an indicator, the system will only accept changes after you have clicked the **Compile** button.

### Creating a new indicator <a href="#creating_a_new_indicator" id="creating_a_new_indicator"></a>

After selecting the **New->Create** menu item for creating a new indicator you will receive a navigation popup with the option to either create a new indicator or import an indicator from a different trading platform:

* **Step 1.** Enter the name
  * Chart-Panel: if this is checked the indicator will be displayed in the charting panel.
  * Indicator-Panel: if this checked the indicator will be displayed beneath the chart.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlrcgwGMxA-24NkMmq%252Findicator_create.png%3Falt%3Dmedia%26token%3D3504dc0c-91c9-402d-a119-2ac33c446725&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=573fd11c&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* **Step 2.** Define parameters.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlrhdcjFHTbQGRcTtM%252Findicator_parameters.png%3Falt%3Dmedia%26token%3De73839f2-540e-414c-8251-b097a2b651a5&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=47a70a9d&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* **Step 3.** Define the Plots-Outputs for visualization of the indicator.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlrosUN8MOE9gSMeS7%252Findicator_plots.png%3Falt%3Dmedia%26token%3D868bc76b-2826-4177-9600-80dbea9674b7&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=5e58eca&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* **Step 4.** Define Level-Lines with the fixed threshold values (if necessary).

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlrzCwfMTZidB3Lunk%252Findicator_lines.png%3Falt%3Dmedia%26token%3D445ca726-26bf-4903-857d-2bd60ec5f252&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=15d105ea&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* **Step 5.** Begin writing the indicator-specific program code.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQls6OOI4OA5T7XE3Pu%252FTrendScript.png%3Falt%3Dmedia%26token%3D300d58bc-547a-4930-a32b-b15f4436289b&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=2f19bb23&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* **Step 6.** Compile the indicator by pressing the <img src="https://2105664868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSb9KiaeLmZhUGHJdWN19%2Fuploads%2FrOGF6hpkUpfsds4ITO3h%2FImg_BuildCombine.png?alt=media&#x26;token=c04bf23f-c6cd-4b48-b41f-c269ec846517" alt="" data-size="line"> button, after which it will become [available](https://docs.agenatrader.com/main/chart-area/untitled/indicators).
  * The compile function is availalbe via Strategy Handling- > Scripting -> Compile

After Indicator would be available in indicator list

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlsY9DtasKmPifWbOg%252Fprogramming%2520indicator.PNG%3Falt%3Dmedia%26token%3D1d2a8aa2-e336-4180-989d-a7ddfcd5ff27&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=d4db2307&#x26;sv=1" alt=""><figcaption></figcaption></figure>

## <img src="https://2105664868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSb9KiaeLmZhUGHJdWN19%2Fuploads%2FyqfPeyYBPRuN67ABImNv%2FImg_ScriptCondition.png?alt=media&#x26;token=defde7f9-19c4-4a34-9e3e-0c2f2837e505" alt="" data-size="line"> Programming of conditions <a href="#scripting__programming_of_conditions" id="scripting__programming_of_conditions"></a>

Select from the main menu **Strategy Handling-> Scripting** followed by **Condition -> New** or **Edit** items to create new or modify existing conditions.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlscTE5YQEVd4UWOPB%252FCondition%2520programming.png%3Falt%3Dmedia%26token%3Db7f1c497-de24-4050-b1d2-592a7e1bf906&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=70f7a6cc&#x26;sv=1" alt=""><figcaption></figcaption></figure>

### Editing conditions <a href="#editing-1" id="editing-1"></a>

If you wish to edit the existing condition, select the **Edit** submenu. You will see the following dialog box.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlsgsNsWxfrHyobOYH%252FEdit%2520condition.PNG%3Falt%3Dmedia%26token%3D2bca7eab-5316-4de6-bb39-85d2554c0b9f&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=50c9091&#x26;sv=1" alt=""><figcaption></figcaption></figure>

*The buttons inside this window have the following functions:*

* Click the **Edit** button or double-click on the entry to open the programming window for the selected condition.
* Click the **Delete** button to remove the selected conditions.
* Click the **Compile** button to compile all indicators, conditions, strategies and alert handlers. If you delete a condition, the system will only accept changes after you have clicked the **Compile** button.

### Creating a new condition <a href="#creating_a_new_condition" id="creating_a_new_condition"></a>

* **Step 1.** Enter the name

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlsr49VQZqdLJ2thTA%252FCondition.png%3Falt%3Dmedia%26token%3D9379d5e2-e6bf-487e-9442-1a0d71927a4c&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=d6226100&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* **Step 2.** Define input parameters

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlt0wCeaF3Ux7fjoca%252FCondition_parameters.png%3Falt%3Dmedia%26token%3D1b2b306a-9dce-4c7c-9445-8edf27316f5e&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=98c8737&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* **Step 3.** Select the condition type: entry, stop or target. This will determine where the condition will appear in the SetupBuilder (EntryEscort, StopEscort or TargetEscort respectively).

Additionally, you can specify the line and color for a condition

* Entry: tba
* Stop occurred: defines the color of the signal fluctuations ("spikes") within the indicator panel; price defines the color within the chart.
* Target: tba

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlt8yMD69JNN0gaQQ8%252FCondition_plots.png%3Falt%3Dmedia%26token%3D195933ec-8446-4a32-aa75-d87b4818d191&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=3081a720&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* **Step 4.** Begin programming the condition-specific code.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQltH62pRGzPJoRC8A7%252FConditionScript.png%3Falt%3Dmedia%26token%3De7cad0a4-a6da-48bc-aae7-be2e907432f1&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=96900b6b&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* **Step 5.** Press the <img src="https://2105664868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSb9KiaeLmZhUGHJdWN19%2Fuploads%2FrOGF6hpkUpfsds4ITO3h%2FImg_BuildCombine.png?alt=media&#x26;token=c04bf23f-c6cd-4b48-b41f-c269ec846517" alt="" data-size="line">  button to make the condition [available](https://docs.agenatrader.com/main/chart-area/untitled/indicators).

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQltTOMjk2yBHRvwnXt%252FIndicator%2520tab.PNG%3Falt%3Dmedia%26token%3D0ccd258a-9ba3-4089-ad5e-1a2728009a43&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=9e96ee09&#x26;sv=1" alt=""><figcaption></figcaption></figure>

## <img src="https://2105664868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSb9KiaeLmZhUGHJdWN19%2Fuploads%2FyYm59r23bPo993J2mR4n%2FImg_ScriptStrategy.png?alt=media&#x26;token=0267310b-ef50-4fae-9937-c197724d433e" alt="" data-size="line"> Programming of strategies <a href="#scripting__programming_of_strategies" id="scripting__programming_of_strategies"></a>

Select from the main menu **Strategy Handling-> Scripting** and then **Strategy -> New** or **Edit** to program new or edit the existing strategy.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQltYpIPv98pQNcV18y%252FStrategy%2520progr.png%3Falt%3Dmedia%26token%3D9e7c1280-541e-4ba6-9e1b-82b78e134c30&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=c72c10e7&#x26;sv=1" alt=""><figcaption></figcaption></figure>

### Editing strategy <a href="#editing-2" id="editing-2"></a>

If you wish to edit the existing strategy, select the **Edit** submenu. You will see the following dialog box:

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQltgLryosnsrVZR4N2%252FEdit%2520strategies.PNG%3Falt%3Dmedia%26token%3Dc8b6be2a-84cb-4ddd-bfea-fc23470aafa3&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=a9e92028&#x26;sv=1" alt=""><figcaption></figcaption></figure>

*The buttons inside this window have the following functions:*

* Click the **Edit** button or double-click on the entry to open the programming window for the selected strategy.
* Click the **Delete** button to remove the selected strategies.
* Click the **Compile** button to compile all indicators, conditions, strategies and alert handlers. If you delete a strategy, the system will only accept changes after you have clicked the **Compile** button.

#### Creating a new strategy <a href="#creating_a_new_strategy" id="creating_a_new_strategy"></a>

After selecting the **New->Create**menu item for creating a new strategy you will receive a navigation popup with the option to either create a new strategy or import a strategy from a different trading platform:

* **Step 1.** Enter the name

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQltoScLCk8ucFb824N%252FStrategy.png%3Falt%3Dmedia%26token%3D5c60ed1f-bcaa-4253-ba4c-8bac38b0b831&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=45dacf26&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* **Step 2.** Define input parameters.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlttkeER0YTtMBN7cp%252FStrategy_parameters.png%3Falt%3Dmedia%26token%3D8f862fd4-d593-48c4-96da-a81cd270a828&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=b4282b26&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* **Step 3.** Begin programming the strategy-specific code.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlu03IuWXkzSeMktXy%252Fstep%25203%2520%281%29.PNG%3Falt%3Dmedia%26token%3Dacb82a2d-c0d8-4c47-8ac2-14aaa56ad05e&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=8218fdee&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* **Step 4.** Press the <img src="https://2105664868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSb9KiaeLmZhUGHJdWN19%2Fuploads%2FrOGF6hpkUpfsds4ITO3h%2FImg_BuildCombine.png?alt=media&#x26;token=c04bf23f-c6cd-4b48-b41f-c269ec846517" alt="" data-size="line"> button to make the strategy [available](https://docs.agenatrader.com/main/chart-area/untitled/strategies).

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQluM3afe7rw3W0PbxT%252FStrategies.PNG%3Falt%3Dmedia%26token%3D986f0a12-9bd0-4202-9a70-09fcbe0170d5&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=bc57a9a1&#x26;sv=1" alt=""><figcaption></figcaption></figure>

## <img src="https://2105664868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSb9KiaeLmZhUGHJdWN19%2Fuploads%2FvKiKKjZQQ3ekBHldTnne%2FImg_ScriptAlert.png?alt=media&#x26;token=10c2a0c5-ef93-4867-ad87-c0d7fb008d7e" alt="" data-size="line"> Programming of Alert Handlers <a href="#scripting__programming_of_alert_handlers" id="scripting__programming_of_alert_handlers"></a>

AgenaTrader's extensive functionalities allow you to code custom price and time alerts within a single (or multiple) self-programmed alert handler(s). Programming in AgenaTrader is based on the Microsoft C#/.net language which enables you to control the system environment and use/code features such as email, SMS, blog entries etc.

Select from the main menu **Strategy Handling-> Scripting** following by **Alert Handler -> New** or **Edit** items to programm new or edit existing alerts.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQluUrUm-Rj2iWb6TS5%252FAlert%2520Handler.png%3Falt%3Dmedia%26token%3D82302192-e8ca-4d6c-95f7-8e04ae6de591&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=dd7542b&#x26;sv=1" alt=""><figcaption></figcaption></figure>

For example, in the **Time alert tab** you can select an entry reason for an alert.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlu_UvZUVo4xiNl7m6%252Fscripting_alertDialog.png%3Falt%3Dmedia%26token%3D4fd2b9fe-6564-4905-b648-4811d5fb1ed5&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=4f10fd13&#x26;sv=1" alt=""><figcaption></figcaption></figure>

Once your price or time alert is triggered, all existing alerts will be opened. You will see the reason for the alert inside this window and can terminate the current alert.

### Editing Alert Handler <a href="#editing-3" id="editing-3"></a>

If you wish to edit the existing alert handler select the **Edit** submenu. You will see the following dialog box:

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQluej8buvfmHFaEhKT%252Fedit%2520alert.PNG%3Falt%3Dmedia%26token%3D44d8b093-28c6-411f-96ec-11617afc07ca&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=62c2f1ad&#x26;sv=1" alt=""><figcaption></figcaption></figure>

*The buttons inside this window have the following functions:*

* Click the **Edit** button or double-click on the entry to open the programming window for the selected alert handler.
* Click the **Delete** button to remove the selected alert handler.
* Click the **Compile** button to compile all indicators, conditions, strategies and alert handlers. If you delete an alert handler, the system will only accept changes after you have clicked the **Compile** button.

### Creating a new Alert Handler <a href="#creating_a_new_alert_handler" id="creating_a_new_alert_handler"></a>

* **Step 1.** Enter the name and a short description.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlupPSdCOumC3nr8-T%252Falert.png%3Falt%3Dmedia%26token%3Df57c0520-b44f-4475-9612-24b45df9b118&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=6623b95b&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* **Step 2.** Click on the **Next** button and begin programming the alert-specific code.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlv-p4FEzl2k2UIhfS%252FStep2.PNG%3Falt%3Dmedia%26token%3D216b9398-ff35-47cd-935e-9c8392b075ba&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=aca9b6a5&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* **Step 3.** Click the <img src="https://2105664868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSb9KiaeLmZhUGHJdWN19%2Fuploads%2FrOGF6hpkUpfsds4ITO3h%2FImg_BuildCombine.png?alt=media&#x26;token=c04bf23f-c6cd-4b48-b41f-c269ec846517" alt="" data-size="line"> button to make the alert handler available (with all other alert handlers). When a price or time alert is triggered, each Alert Handler will search for ways to handle it, if necessary.

### Example. Alert Handler for sending emails <a href="#example-._alert_handler_for_sending_emails" id="example-._alert_handler_for_sending_emails"></a>

A straightforward way to integrate a price or time alert with the Alert Handler is by utilizing the alert reason. For instance, if the alert reason field includes "Send Email," the programmed alert will activate immediately once the alert handler detects this reason.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlvJD7aMgBoi9zkXxU%252FStep3.PNG%3Falt%3Dmedia%26token%3D353627c6-d14c-490e-b22a-8981371cd128&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=abfd8145&#x26;sv=1" alt=""><figcaption></figcaption></figure>

## <img src="https://2105664868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSb9KiaeLmZhUGHJdWN19%2Fuploads%2FbOTu81vDv70mfZgZYeMt%2FImg_Output.png?alt=media&#x26;token=efd9fd8e-b61d-472d-a2e9-eeb5fd4eca58" alt="" data-size="line"> Output window <a href="#output-window" id="output-window"></a>

The output tab displays messages that have been built into self-programmed indicators, strategies, alert handlers, etc. based on the print method.

This tab can also be used for troubleshooting (debugging), but besides this it has no other functionalities.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlvMqX5gYTPxzUX8Rn%252Foutput%2520window.png%3Falt%3Dmedia%26token%3D77111583-c8a1-4140-b109-fcedba6ec979&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=be471a5f&#x26;sv=1" alt=""><figcaption></figcaption></figure>

Right click in the tab and select the **Clear** option to delete all entries in the output tab.

## <img src="https://2105664868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSb9KiaeLmZhUGHJdWN19%2Fuploads%2Fw8OmHGCLjr6COibb9QqA%2FImg_Reference.png?alt=media&#x26;token=f936dd8e-80e2-4628-8ce0-2b4103c0f9e4" alt="" data-size="line"> Scripting references <a href="#scripting-references" id="scripting-references"></a>

Select **Strategy Handling-> Scripting** following by **Scripting references** from the menu to load the necessary references for programming or to edit them.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlvQgSVgusYe8CQGJd%252FScripting%2520reference.png%3Falt%3Dmedia%26token%3D5bd26e5d-abe9-46fb-b0ea-1323a62158d6&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=9d6d114c&#x26;sv=1" alt=""><figcaption></figcaption></figure>

The following window will be opened:

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlkXnxEvvGK-rs8ZpV%252F-MQlvU9SVhhs1la2zt9w%252Fscripting%2520references.PNG%3Falt%3Dmedia%26token%3Dcf92bb9a-f20f-482c-86a1-2cd6051c8a16&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=ee21f657&#x26;sv=1" alt=""><figcaption></figcaption></figure>

The references can be selected from the top tabs **.Net, COM** and **Browse**.

*The buttons inside this window have the following functions:*

* Click the **Add** button to attach the references to the reference list.
* Click the **Remove** button to delete a reference from the reference list.
* Click the **OK** button to accept the changes.

## <img src="https://2105664868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSb9KiaeLmZhUGHJdWN19%2Fuploads%2FrOGF6hpkUpfsds4ITO3h%2FImg_BuildCombine.png?alt=media&#x26;token=c04bf23f-c6cd-4b48-b41f-c269ec846517" alt="" data-size="line"> Compile <a href="#scripting__compile" id="scripting__compile"></a>

To integrate self-programmed alert handlers, indicators, conditions, strategies, or conditions compiled from external sources using **Signal Builder** into AgenaTrader, copy the \*.CSV file from **Documents/AgenaTrader/UserCode/** into the corresponding subfolder "Scripted alert handlers (indicators, conditions, strategies)" or into the **Signal Builder** subfolder. Then select **Strategy Handling-> Scripting -> Compile** to make these available within AgenaTrader.

**Directory structure**

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlvW_NcVCkiaT0Hw_5%252F-MQlwGPBn-I6UtXTvc5s%252Fdirectory_structure_eng.png%3Falt%3Dmedia%26token%3D5d3ff019-c23a-4248-91df-5c4275c6ef19&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=d66e7a0b&#x26;sv=1" alt=""><figcaption></figcaption></figure>

### **Compiling errors**

If the compilation procedure generates errors, this information will appear in a dialog box indicating where the error comes from.

1\. Display Error description 2. Display file name. Left click on file name will open file location.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlvW_NcVCkiaT0Hw_5%252F-MQlwOwfaNZNQ-stZ4E0%252FCompilation_Error.png%3Falt%3Dmedia%26token%3D22a147fe-95f3-4415-9d1d-aa126bf10f05&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=245e1a3a&#x26;sv=1" alt=""><figcaption></figcaption></figure>

You may use the Visual Studio instead of the internal Script (programming environment) just activate **Use Visual Studio** checkbox in Global Configuration

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlvW_NcVCkiaT0Hw_5%252F-MQlwTm8jMzSGiFhayPe%252Fconfiguration%2520%281%29.png%3Falt%3Dmedia%26token%3D244f2787-128c-4011-8bc7-15782574786d&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=131ddb68&#x26;sv=1" alt=""><figcaption></figcaption></figure>

#### Scripted Conditions Error <a href="#scripted_conditions_error" id="scripted_conditions_error"></a>

In order to solve the issue User should verify conditions scripts and try to compile again.

* Select from the main menu **Strategy Handling-> Scripting**-> **Condition** ->**Edit** items to verify condition.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlvW_NcVCkiaT0Hw_5%252F-MQlwX_NMDIk2hiZOVOB%252FCondition%2520programming%2520%281%29.png%3Falt%3Dmedia%26token%3Df07e7533-59c3-4b48-98fa-88fa58789284&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=233979be&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* In the following dialog box click the **Edit** button or double-click on the entry to open the programming window for the selected condition.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlvW_NcVCkiaT0Hw_5%252F-MQlwa23yJJi9_wooSg0%252FEdit%2520condition%2520%281%29.PNG%3Falt%3Dmedia%26token%3Dee47be3f-d153-477c-a2b0-1b48aeeb9a67&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=2da429aa&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* Check and correct the condition-specific code. After click **Compile** <img src="https://2105664868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSb9KiaeLmZhUGHJdWN19%2Fuploads%2FrOGF6hpkUpfsds4ITO3h%2FImg_BuildCombine.png?alt=media&#x26;token=c04bf23f-c6cd-4b48-b41f-c269ec846517" alt="" data-size="line"> (in Visual Studio the Build) button.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlvW_NcVCkiaT0Hw_5%252F-MQlwkcLjV3H_Rq2sO7w%252FConditionScript%2520%281%29.png%3Falt%3Dmedia%26token%3D959cb3a2-72c5-40ce-9386-dc595126fb44&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=77f24345&#x26;sv=1" alt=""><figcaption></figcaption></figure>

### Scripted Indicator Error <a href="#scripted_indicator_error" id="scripted_indicator_error"></a>

In order to solve the issue User should verify indicator scripts and try to compile again.

* Select the **Strategy Handlings-> Scripting**->\_\_Indicator -> Edit to verify indicator.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlvW_NcVCkiaT0Hw_5%252F-MQlwp_n2A50C-M5ExZK%252FScripting%2520%281%29.png%3Falt%3Dmedia%26token%3D14972c63-9618-48d8-bcca-d9940455ac92&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=f7f0a011&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* In the following dialog box click the **Edit** button or double-click on the entry to open the programming window for the selected indicator.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlvW_NcVCkiaT0Hw_5%252F-MQlwxyi_1HEz0V756hR%252FEdit%2520indicators%2520%281%29.PNG%3Falt%3Dmedia%26token%3Db5f94191-9c23-481d-9c8f-54448f79e724&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=56b872c2&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* Check and correct the indicator-specific code. After click **Compile** <img src="https://2105664868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSb9KiaeLmZhUGHJdWN19%2Fuploads%2FrOGF6hpkUpfsds4ITO3h%2FImg_BuildCombine.png?alt=media&#x26;token=c04bf23f-c6cd-4b48-b41f-c269ec846517" alt="" data-size="line"> (in Visual Studio the Build) button.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlvW_NcVCkiaT0Hw_5%252F-MQlx5rRhbhOA6CvlPDL%252FTrendScript%2520%281%29.png%3Falt%3Dmedia%26token%3D6d9f5999-580c-421d-9e5d-6fda9eb77293&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=d242345f&#x26;sv=1" alt=""><figcaption></figcaption></figure>

### Scripted Strategies Error <a href="#scripted_strategies_error" id="scripted_strategies_error"></a>

In order to solve the issue User should verify strategy scripts and try to compile again.

* Select from the main menu **Strategy Handling-> Scripting** -> **Strategy ->** Edit item to verify condition. strategy.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlvW_NcVCkiaT0Hw_5%252F-MQlxCR4u7I0Ic9BTgaf%252FStrategy%2520progr%2520%281%29.png%3Falt%3Dmedia%26token%3D49634dc1-eb57-42b2-9903-6c857e1a2b0b&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=cdda7272&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* In the following dialog box click the **Edit** button or double-click on the entry to open the programming window for the selected strategy.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlvW_NcVCkiaT0Hw_5%252F-MQlxGMyyXsek3LP_ofn%252FEdit%2520strategies%2520%281%29.PNG%3Falt%3Dmedia%26token%3D5e354c97-36d2-4e69-8f37-fcc7af162f1f&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=d1b299f5&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* Check and correct the strategy-specific code. After you finished click **Compile** <img src="https://2105664868-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSb9KiaeLmZhUGHJdWN19%2Fuploads%2FrOGF6hpkUpfsds4ITO3h%2FImg_BuildCombine.png?alt=media&#x26;token=c04bf23f-c6cd-4b48-b41f-c269ec846517" alt="" data-size="line"> (in Visual Studio the Build) button.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQlvW_NcVCkiaT0Hw_5%252F-MQlxVqZ6eCpoGJ1RMc4%252Fstep%25203%2520%282%29.PNG%3Falt%3Dmedia%26token%3Dd73b2940-ebc1-4295-abd4-0e95ce85097f&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=18f8cccb&#x26;sv=1" alt=""><figcaption></figcaption></figure>

### Сonditions and Scripts are disappeared

There are several ways to solve this issue:

* Download and install the latest release of AgenaTrader. Download link [**here**](https://agenatrader.com/download/AgenaTrader_Setup.exe)
* Please go to **Strategie Handling->Scripting** and click on **Compile** button

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQwPCScTa47vxWsw7R-%252F-MQwSPttYe-vLXDqb4wR%252Fcompile.png%3Falt%3Dmedia%26token%3D311797e0-68a8-475e-8f2e-b0f805d221f5&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=8ce7e364&#x26;sv=1" alt=""><figcaption></figcaption></figure>

**Important!** In some cases, User can get compiling errors. Please find details about how to solve this on page [**Compile Errors**](https://docs.agenatrader.com/create-your-own-trading-strategy/scripting#Compile_Errors)

* Please check the destination of script files. They should be located: **C:\Users\\'User\_name'\Documents\AgenaTrader\UserCode\ folders: Indicators, Scanns, ScriptedConditions, Strategies or AlertHandlers** (depends on Script type). In case you find them in other location, just copy them to the destination folder and click **Compile** button.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQwPCScTa47vxWsw7R-%252F-MQwSWK4SBrzzYyYCWzy%252FUserCode.png%3Falt%3Dmedia%26token%3D642aec75-d030-42b9-9941-2f2a80b1943b&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=f93d0bc2&#x26;sv=1" alt=""><figcaption></figcaption></figure>

* Conditions might disappear because your packages were not updated to the latest version. In this case please select **Tools -> Packages -> Imported Packages** from the main menu.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQwPCScTa47vxWsw7R-%252F-MQwSaeyb9-W5KlGufP6%252FPAckage.png%3Falt%3Dmedia%26token%3D384a26ca-f4ee-4e2a-8938-e9f6a2ad4ea8&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=7a140bed&#x26;sv=1" alt=""><figcaption></figcaption></figure>

In open tab please check version of your add on. **Up-to-date** button means that your addon is already updated.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQwPCScTa47vxWsw7R-%252F-MQwSl293RFC8DJc-JDz%252F1.png%3Falt%3Dmedia%26token%3D8a1c5d78-7cd0-4278-96d4-1880241546a3&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=c20537ef&#x26;sv=1" alt=""><figcaption></figcaption></figure>

**Update Available** means that you add on version is obsolete.

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQwPCScTa47vxWsw7R-%252F-MQwSpp-WmkFnvcFC3zs%252Fupdate.png%3Falt%3Dmedia%26token%3D19ccea19-5675-4ec3-9286-5090a5018de0&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=47c5c909&#x26;sv=1" alt=""><figcaption></figcaption></figure>

To update add on please click on **Update Available** button and in open dialog click button **Yes**

<figure><img src="https://docs.agenatrader.com/~gitbook/image?url=https%3A%2F%2F2805764894-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-legacy-files%2Fo%2Fassets%252F-MKZSsJBtSP9L4sqIe_q%252F-MQwPCScTa47vxWsw7R-%252F-MQwSuTucB9H3XV1ht-U%252FUpdate_routine.png%3Falt%3Dmedia%26token%3Dbb2aca7d-541b-4d37-952b-5af1ba490a82&#x26;width=768&#x26;dpr=4&#x26;quality=100&#x26;sign=b989ab1d&#x26;sv=1" alt=""><figcaption></figcaption></figure>
