AgenaTrader Docs
HomeIndicatorsAgenaScriptRelease Notes
English
English
  • šŸ¤AgenaTrader Online Help
  • Introduction
    • Overview
      • Supported Instruments and Order Processing
      • License Versions
      • Hardware and system requirements
      • Licensing, Programming, Costs, and Support Overview
    • Video Guide
      • AgenaTrader Docs
    • Glossary
    • FAQ
      • Top FAQ
        • Chart is ticking without displaying candles
        • How to display P&L on Tradebar
        • Connecting to more than one CFD-Broker simultaneously
        • Hard and Soft stops: Automatic stop movement
        • Which order connections does my broker support
        • Š”onditions and Scripts disappeared
        • Trading Functions Are Disabled
        • IB Charts Not Displayed Correctly or Contain Incorrect Data
        • Can I Connect an Additional Data Feed While Using IB as a Broker?
    • Contact Support
  • Main
    • Broker and Datafeeds Connections
      • AgenaBroker
      • Technology Provider
      • Connections
      • Simulated account
      • Datafeed
      • Broker
    • Set Up Your Workspace
    • Chart Area
      • Charting
      • Chart Types
      • Chart Tools
      • Chart Context Menu
    • Chart Trading
    • Order Management
    • OptionTrading
    • Realtime Scanner
    • OrderStream
    • ActionBar
    • Main Menu
  • TOOLS
    • Preferences
    • Mappings and Instrument-Lists
    • Instrument Editor
    • Tools Menu
    • Trading Information
    • System Information
  • Create your own strategy
    • Semi automated trading
    • AgenaTrader++ (plusplus) – Automated Setup & Recovery Management
    • AT (plusplus) Manager
    • Setup Builder
    • Signal Builder
    • Risk and Money management
    • Strategy Manager
    • AgenaScript
    • Scripting
  • Package
    • Package first steps
    • AddOns (packages) and their content
    • Internal Packages
    • External Packages
    • Using AddOn- and package-indicators in scripted components
Powered by GitBook
On this page
  • Agena indicator
  • Scripting
  • Scripting environment
  • Scripting toolbar
  • Visual Studio
  • AgenaTrader and Visual Studio
  • Programming of indicators
  • Editing indicators
  • Creating a new indicator
  • Programming of conditions
  • Editing conditions
  • Creating a new condition
  • Programming of strategies
  • Editing strategy
  • Programming of Alert Handlers
  • Editing Alert Handler
  • Creating a new Alert Handler
  • Example. Alert Handler for sending emails
  • Output window
  • Scripting references
  • Compile
  • Compiling errors
  • Scripted Indicator Error
  • Scripted Strategies Error
  • Š”onditions and Scripts are disappeared
  1. Create your own strategy

Scripting

Last updated 2 months ago

Agena indicator

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

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.

Scripting toolbar

Icon

Function

Loads existing self-programmed indicators/strategies to the workspace

Saves source code changes

Cuts marked source code

Copies marked source code

Pastes copied / cut source code

Enables comments on marked source code parts

Uncomments the selected lines

Cancels previous action(s)

Repeats cancelled action(s)

Opens output window

Opens reference popup

Compiles sources

Searches for a text within source code

Find/Replace

Opens list of errors

Deletes file

Visual Studio

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

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

AgenaTrader and Visual Studio

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

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.

Please note that the download and the installation of the software take about 60 minutes!

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

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

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

Editing indicators

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

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

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.

  • Step 2. Define parameters.

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

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

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

    • The compile function is availalbe via Strategy Handling- > Scripting -> Compile

After Indicator would be available in indicator list

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

Editing conditions

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

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

  • Step 1. Enter the name

  • Step 2. Define input parameters

  • 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

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

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

Editing strategy

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

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

After selecting the New->Createmenu 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

  • Step 2. Define input parameters.

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

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.

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

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

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

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

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

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

Example. Alert Handler for sending emails

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.

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.

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

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

The following window will be opened:

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.

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

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.

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

Scripted Conditions Error

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.

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

Scripted Indicator Error

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.

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

Scripted Strategies Error

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.

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

Дonditions and Scripts are disappeared

There are several ways to solve this issue:

  • Please go to Strategie Handling->Scripting and click on Compile button

  • 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.

  • 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.

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

Update Available means that you add on version is obsolete.

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

Download: Download:

This article was created by

You can download the free ā€œVisual Studio Communityā€ edition at .

This article was created by

Programming of indicators

Step 6. Compile the indicator by pressing the button, after which it will become .

Programming of conditions

Step 5. Press the button to make the condition .

Programming of strategies

Step 4. Press the button to make the strategy .

Programming of Alert Handlers

Step 3. Click the 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.

Output window

Scripting references

Compile

Check and correct the condition-specific code. After click Compile (in Visual Studio the Build) button.

Check and correct the indicator-specific code. After click Compile (in Visual Studio the Build) button.

Check and correct the strategy-specific code. After you finished click Compile (in Visual Studio the Build) button.

Download and install the latest release of AgenaTrader. Download link

Important! In some cases, User can get compiling errors. Please find details about how to solve this on page

Latest Version of Visual Studio
Older Versions of Visual Studio
http://script-trading.com.
https://www.visualstudio.com/downloads
http://script-trading.com.
here
Compile Errors
Agena indicator Help Guide
available
available
available