> For the complete documentation index, see [llms.txt](https://script.agenatrader.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://script.agenatrader.com/handling-bars-and-instruments/instruments.md).

# Instruments

The term "instrument" denotes a tradable value such as a stock, ETF, future etc.

An instrument has various properties that can be used in AgenaScripts created by the user:

[*Instrument.Compare*](#instrumentcompare)

[*Instrument.Currency*](#instrumentcurrency)

[*Instrument.Digits*](#instrumentdigits)

[*Instrument.ETF*](#instrumentetf)

[*Instrument.Exchange*](#instrumentexchange)

[*Instrument.Expiry*](#instrumentexpiry)

[*Instrument.GetCurrencyFactor*](#instrumentgetcurrencyfactor)

[*Instrument.InstrumentType*](#instrumentinstrumenttype)

[*Instrument.MainSector*](#instrumentmainsector)

[*Instrument.Margin*](#instrumentmargin)

[*Instrument.Name*](#instrumentname)

[*Instrument.PointValue*](#instrumentpointvalue)

[*Instrument.Round2TickSize*](#instrumentround2ticksize)

[*Instrument.Symbol*](#instrumentsymbol)

[*Instrument.TickSize*](#instrumentticksize)

With the **OnCalculate()** method you can use any properties you wish without having to test for a null reference. As soon as the **OnCalculate()** function is called up by AgenaScript, an object will become available. If you wish to use these properties outside of **OnCalculate()**, you should first perform a test for null references using **if** (Bars != **null**)

## Instrument.Compare <a href="#instrumentcompare" id="instrumentcompare"></a>

#### Description <a href="#description_55" id="description_55"></a>

The Instrument.Compare function compares two market prices whilst taking into account the correct number of decimal points. The smallest possible price change is displayed by the value TickSize. This function simplifies the otherwise time-consuming comparison using floating-point operations.

#### Parameter <a href="#parameter_42" id="parameter_42"></a>

double value1 double value2

#### Return value <a href="#return-value_28" id="return-value_28"></a>

Type int

1 - value1 is bigger than value2 -1 - value1 is smaller than value2 0 - value1 and value2 are equal

#### Usage <a href="#usage_53" id="usage_53"></a>

```csharp
Instrument.Compare(double Value1, double Value2)
```

#### More Information <a href="#more-information_40" id="more-information_40"></a>

**Be aware this function compares prices based on TickSize.** If the ticksize of your instrument is 0.01 these prices will be rounded and compared on 2 decimal digits. If you want a regular comparation of two numbers, you should use the operator "greater than" (>) or the operator "smaller than" (<).

More infomation about [math.round()](https://msdn.microsoft.com/en-us//library/75ks3aby\(v=vs.110\).aspx)

If the tick size is 0,00001 – as it usually is with FX values – then the following will be displayed:

Compare(2, 1.99999) a 1, meaning 2 is bigger than 1.99999 Compare(2, 2.000001) a 0, meaning the values are equal Compare(2, 1.999999) a 0, meaning the values are equal Compare(2, 2.00001) a -1, meaning 2 is smaller than 2.00001

#### Example <a href="#example_50" id="example_50"></a>

```csharp
Print(Instrument.Compare(2, 1.999999));
```

## Instrument.Currency <a href="#instrumentcurrency" id="instrumentcurrency"></a>

#### Description <a href="#description_56" id="description_56"></a>

Instrument.Currency outputs a currency object that contains the corresponding currency in which the instrument is traded.

#### Parameter <a href="#parameter_43" id="parameter_43"></a>

None

#### Return Value <a href="#return-value_29" id="return-value_29"></a>

A constant of the type "public enum currencies"

#### Usage <a href="#usage_54" id="usage_54"></a>

Instrument.Currency

#### More Information <a href="#more-information_41" id="more-information_41"></a>

The common currencies are: AUD, CAD, EUR, GBP, JPY or USD.

#### Example <a href="#example_51" id="example_51"></a>

```csharp
Print(Instrument.Name + " is traded in " + Instrument.Currency);
```

## Instrument.Digits <a href="#instrumentdigits" id="instrumentdigits"></a>

#### Description <a href="#description_57" id="description_57"></a>

Instrument.Digits outputs the number of decimal points in which the market price of the instrument is traded.

#### Parameter <a href="#parameter_44" id="parameter_44"></a>

none

#### Return Value <a href="#return-value_30" id="return-value_30"></a>

int Digits

#### Usage <a href="#usage_55" id="usage_55"></a>

Instrument.Digits

#### More Information <a href="#more-information_42" id="more-information_42"></a>

Stocks are usually traded to two decimal points. Forex can be traded (depending on the data provider) with 4 or 5 decimal places.

This function is especially useful when formatting the output of various instruments that need rounding. Also see [*TickSize*](/keywords.md#ticksize) and [*Instrument.Round2Ticks*](#instrumentround2ticksize), [*Instrument.Round2TickSize*](#instrumentround2ticksize).

More information can be found here: *Formatting of Numbers*.

#### Example <a href="#example_52" id="example_52"></a>

```csharp
Print("The value of " +Instrument.Name + " is noted with a precision of " + Instrument.Digits +" Decimal points.");
```

## Instrument.ETF <a href="#instrumentetf" id="instrumentetf"></a>

#### Description <a href="#description_58" id="description_58"></a>

Instrument.ETF is used to differentiate between a stock and an ETF. This is necessary since ETFs are considered to be „stocks" by some exchanges.

#### Parameter <a href="#parameter_45" id="parameter_45"></a>

none

#### Return Value <a href="#return-value_31" id="return-value_31"></a>

Type bool

#### Usage <a href="#usage_56" id="usage_56"></a>

Instrument.ETF

#### More Information <a href="#more-information_43" id="more-information_43"></a>

What is an ETF?

Wikipedia: [*http://de.wikipedia.org/wiki/Exchange-traded\_fund*](http://de.wikipedia.org/wiki/Exchange-traded_fund*)

#### Example <a href="#example_53" id="example_53"></a>

```csharp
if (Instrument.InstrumentType == InstrumentType.Stock)
if (Instrument.ETF)
Print("The value is an ETF.");
else
Print("The value is a stock.");
```

## Instrument.Exchange <a href="#instrumentexchange" id="instrumentexchange"></a>

#### Description <a href="#description_59" id="description_59"></a>

Instrument.Exchange outputs the description/definition of the current exchange for the current instrument.

#### Parameter <a href="#parameter_46" id="parameter_46"></a>

none

#### Return Value <a href="#return-value_32" id="return-value_32"></a>

An exchange object of the type "public enum exchanges"

#### Usage <a href="#usage_57" id="usage_57"></a>

Instrument.Exchange

#### More Information <a href="#more-information_44" id="more-information_44"></a>

An overview of various exchange: *<https://en.wikipedia.org/wiki/List\\_of\\_stock\\_exchanges>*

#### Example <a href="#example_54" id="example_54"></a>

```csharp
Print("The instrument " + Instrument.Name +" is traded on the " + Instrument.Exchange + " exchange.");
```

## Instrument.Expiry <a href="#instrumentexpiry" id="instrumentexpiry"></a>

#### Description <a href="#description_60" id="description_60"></a>

Instrument.Expiry outputs the date (month and year) of the expiry of a financial instrument. Only derivative instruments such as options or futures will have an expiry date.

#### Parameter <a href="#parameter_47" id="parameter_47"></a>

None

#### Return Value <a href="#return-value_33" id="return-value_33"></a>

Type DateTime

For instruments without an expiry date the returned value is set to DateTime.MaxValue(= 31.12.9999 23.59:59)

#### Usage <a href="#usage_58" id="usage_58"></a>

Instrument.Expiry

#### More Information <a href="#more-information_45" id="more-information_45"></a>

The expiry date (expiry) can also be seen within the Instrument Escort:

![](https://3984528791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSWsZPE35pbN2CTsq7pus%2Fuploads%2FtzPMC5tadRDqHIb37geS%2FExpiry.jpg?alt=media\&token=4d4e09e6-cdeb-4e66-bfbb-a93ec84278fa)

#### Example <a href="#example_55" id="example_55"></a>

```csharp
Print("The instrument " + Instrument.Name +" will expire on " + Instrument.Expiry);
```

## Instrument.GetCurrencyFactor <a href="#instrumentgetcurrencyfactor" id="instrumentgetcurrencyfactor"></a>

#### Description <a href="#description_61" id="description_61"></a>

Instrument.GetCurrencyFactor returns a conversion factor that can be used to convert an instrument's currency to the account's currency.

#### Parameter <a href="#parameter_48" id="parameter_48"></a>

Type Currencies

#### Return Value <a href="#return-value_34" id="return-value_34"></a>

Type double

#### Usage <a href="#usage_59" id="usage_59"></a>

Instrument.GetCurrencyFactor(Currencies)

#### More Information <a href="#more-information_46" id="more-information_46"></a>

Common currencies are.B. AUD, CAD, EUR, GBP, JPY oder USD.

#### Example <a href="#example_56" id="example_56"></a>

```csharp
Protected override void OnCalculate()
{
   double currFactor = Instrument.GetCurrencyFactor(Account.Currency);
   Print(Close[0] + " in " + Instrument.Currency.ToString() + " = " + (Close[0] * currFactor) + " in " + Account.Currency.ToString());
}
```

## Instrument.InstrumentType <a href="#instrumentinstrumenttype" id="instrumentinstrumenttype"></a>

#### Description <a href="#description_62" id="description_62"></a>

Instrument.InstrumentType outputs a type object of the trading instrument.

#### Parameter <a href="#parameter_49" id="parameter_49"></a>

none

#### Return Value <a href="#return-value_35" id="return-value_35"></a>

Object of the type "public enum instrument"

#### Usage <a href="#usage_60" id="usage_60"></a>

Instrument.InstrumentType

#### More Information <a href="#more-information_47" id="more-information_47"></a>

Potential values are: future, stock, index, currency, option, CFD and unknown.

There is no ETF type. ETFs are considered to be of the type "stock" – see [*Instrument.ETF*](#instrumentetf).

The instrument type can also be viewed within the Instrument Escort:

![](https://3984528791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSWsZPE35pbN2CTsq7pus%2Fuploads%2FuMUAvL98no9BxGU5LyMC%2FInstrumentTypeFGBL.jpg?alt=media\&token=c0f0b225-97d5-4d5f-9101-f153045adb0d)

#### Example <a href="#example_57" id="example_57"></a>

```csharp
Print("The instrument " + Instrument.Name + " is of the type " + Instrument.InstrumentType);
```

## Instrument.MainSector <a href="#instrumentmainsector" id="instrumentmainsector"></a>

#### Description <a href="#description_63" id="description_63"></a>

Instrument.MainSector returns the main sector of the trading instrument.

#### Parameter <a href="#parameter_50" id="parameter_50"></a>

none

#### Return Value <a href="#return-value_36" id="return-value_36"></a>

String

#### Usage <a href="#usage_61" id="usage_61"></a>

Instrument.MainSector

#### More Information <a href="#more-information_48" id="more-information_48"></a>

The main sector is also visible in the instrument escort:

![](https://3984528791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSWsZPE35pbN2CTsq7pus%2Fuploads%2FuMUAvL98no9BxGU5LyMC%2FInstrumentTypeFGBL.jpg?alt=media\&token=c0f0b225-97d5-4d5f-9101-f153045adb0d)

#### Example <a href="#example_58" id="example_58"></a>

```csharp
Print("Das Instrument " + Instrument.Name + " ist im Sektor " + Instrument.MainSector + " tätig.");
```

## Instrument.Margin <a href="#instrumentmargin" id="instrumentmargin"></a>

#### Description <a href="#description_64" id="description_64"></a>

Instrument.MainSector returns the required margin of the trading instrument.

#### Parameter <a href="#parameter_51" id="parameter_51"></a>

none

#### Return Value <a href="#return-value_37" id="return-value_37"></a>

int

#### Usage <a href="#usage_62" id="usage_62"></a>

Instrument.Margin

#### More Information <a href="#more-information_49" id="more-information_49"></a>

Margin is also visible in the instrument escort:

![](https://3984528791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSWsZPE35pbN2CTsq7pus%2Fuploads%2F28x3441VQl66a6JS0zhY%2FMarginFGBL.jpg?alt=media\&token=4963e0ba-e85a-44b8-b109-c20d7e41d677)

#### Example <a href="#example_59" id="example_59"></a>

```csharp
Print("Das Instrument " + Instrument.Name + " has a margin of " + Instrument.Margin);
```

## Instrument.Name <a href="#instrumentname" id="instrumentname"></a>

#### Description <a href="#description_65" id="description_65"></a>

Instrument.Name outputs the name/description of the trading instrument.

#### Parameter <a href="#parameter_52" id="parameter_52"></a>

none

#### Return Value <a href="#return-value_38" id="return-value_38"></a>

Type string

#### Usage <a href="#usage_63" id="usage_63"></a>

Instrument.Name

#### More Information <a href="#more-information_50" id="more-information_50"></a>

The instrument name can also be seen within the Instrument Escort:

![](https://3984528791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSWsZPE35pbN2CTsq7pus%2Fuploads%2FMdNkgryys6mJQHtvd8Zd%2FName_Fdax.jpg?alt=media\&token=0e0986d5-3278-4693-88a7-83b1253481a0)

#### Example <a href="#example_60" id="example_60"></a>

```csharp
Print("The currently loaded instrument inside the chart is named " + Instrument.Name);
```

## Instrument.PointValue <a href="#instrumentpointvalue" id="instrumentpointvalue"></a>

#### Description <a href="#description_66" id="description_66"></a>

Instrument.PointValue outputs the monetary value for a full point movement of the instrument.

#### Parameter <a href="#parameter_53" id="parameter_53"></a>

none

#### Return Value <a href="#return-value_39" id="return-value_39"></a>

double – point value

#### Usage <a href="#usage_64" id="usage_64"></a>

Instrument.PointValue

#### More Information <a href="#more-information_51" id="more-information_51"></a>

**Example for various point values** (per amount, CFD, futures contract, lot etc.)

Stock: generally 1.00 Euro or 1.00 USD. EUR/USD: 100,000 USD DAX future: 25.00 Euro

**Tick Value**

The tick value can be calculated by multiplying the point value with the tick size.

For example, the E-mini S\&P 500 has a point value of $50. The tick size equals 0.25. This means that there are 4 ticks in one full point for the E-mini S\&P 500. Since 50 \* 0.25 = 50/4 this means that the tick value is $12.50.

The point value can also be viewed within the Instrument Escort:

![](https://3984528791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSWsZPE35pbN2CTsq7pus%2Fuploads%2FgIGzwbBnjcCtsUdt3UEM%2FFdax_PointValue.jpg?alt=media\&token=025d226d-fb24-4057-9f7e-e741a8ba63f2)

#### Example <a href="#example_61" id="example_61"></a>

```csharp
Print("When " + Instrument.Name + " rises for one full point then this is equal to " + Instrument.PointValue + " " + Instrument.Currency);
```

## Instrument.Round2TickSize <a href="#instrumentround2ticksize" id="instrumentround2ticksize"></a>

#### Description <a href="#description_67" id="description_67"></a>

The function Instrument.Round2TickSize rounds the supplied market price to the smallest value divisible by the tick size of the instrument.

#### Parameter <a href="#parameter_54" id="parameter_54"></a>

double – market value

#### Return value <a href="#return-value_40" id="return-value_40"></a>

double

#### Usage <a href="#usage_65" id="usage_65"></a>

```csharp
Instrument.Round2TickSize(double MarketPrice)
```

#### More Information <a href="#more-information_52" id="more-information_52"></a>

The number of decimal places to which the price is rounded depends on the instrument. If, for example, an instrument is a stock, then the rounding will be performed to 2 decimal places. For a Forex instrument, it may be carried out to 4 or 5 decimal places.

See [*TickSize*](/keywords.md#ticksize) and [*Instrument.Digits*](#instrumentdigits).

Example of professional *Formatting*, *Formatting of Numbers*.

#### Example <a href="#example_62" id="example_62"></a>

```csharp
double Price = 12.3456789;
Print(Price + " rounded for a " + Instrument.Name + " valid value is " + Instrument.Round2TickSize(Price));
```

## Instrument.Symbol <a href="#instrumentsymbol" id="instrumentsymbol"></a>

#### Description <a href="#description_68" id="description_68"></a>

Instrument.Symbol outputs the symbol that identifies the trading instrument within AgenaTrader. Depending on the symbol, the mappings for the various data feed providers and brokers will be managed in different ways.

#### Parameter <a href="#parameter_55" id="parameter_55"></a>

none

#### Return value <a href="#return-value_41" id="return-value_41"></a>

Type string

#### Usage <a href="#usage_66" id="usage_66"></a>

Instrument.Symbol

#### More Information <a href="#more-information_53" id="more-information_53"></a>

By using symbols, identical stocks being traded on different exchanges can be identified and separated from each other. The symbol BMW\.DE is the BMW stock on the XETRA exchange. BMW\.CFG is the CFD for the BMW stock.

The instrument symbol can also be viewed within the Instrument Escort:

![](https://3984528791-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSWsZPE35pbN2CTsq7pus%2Fuploads%2FOs6rM4lWesU7UWcRwVLI%2FFdax_Symbol.jpg?alt=media\&token=7ef959b8-dc65-40f6-bd2e-8828cbba025f)

#### Example <a href="#example_63" id="example_63"></a>

```csharp
Print("The instrument currently loaded within the chart has the symbol: " + Instrument.Symbol);
```

## Instrument.TickSize <a href="#instrumentticksize" id="instrumentticksize"></a>

#### Description <a href="#description_69" id="description_69"></a>

The tick size is the smallest measurable unit that a financial instrument can move. This is usually called 1 tick.

#### Parameter <a href="#parameter_56" id="parameter_56"></a>

none

#### Return Value <a href="#return-value_42" id="return-value_42"></a>

double

#### Usage <a href="#usage_67" id="usage_67"></a>

Instrument.TickSize or simply TickSize

#### More Information <a href="#more-information_54" id="more-information_54"></a>

The keyword [*TickSize*](/keywords.md#ticksize) is equivalent to Instrument.TickSize. Both information requests will produce the same value and are thus interchangeable.

#### Example <a href="#example_64" id="example_64"></a>

Stock: 0.01 ES future: 0.25 EUR/USD: 0.00001

See [*Instrument.PointValue*](#instrumentpointvalue) and [*Instrument.Digits*](#instrumentdigits).

Examples of professional *Formatting*, *Formatting of Numbers*.

#### Example <a href="#example_65" id="example_65"></a>

```csharp
Print("The value of " + Instrument.Name + " can change for a minimum of " + Instrument.TickSize + " Tick(s).");
```
