Instruments
Last updated
Last updated
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:
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)
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.
double value1 double value2
Type int
1 - value1 is bigger than value2 -1 - value1 is smaller than value2 0 - value1 and value2 are equal
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" (<).
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
Instrument.Currency outputs a currency object that contains the corresponding currency in which the instrument is traded.
None
A constant of the type "public enum currencies"
Instrument.Currency
The common currencies are: AUD, CAD, EUR, GBP, JPY or USD.
Instrument.Digits outputs the number of decimal points in which the market price of the instrument is traded.
none
int Digits
Instrument.Digits
Stocks are usually traded to two decimal points. Forex can be traded (depending on the data provider) with 4 or 5 decimal places.
More information can be found here: Formatting of Numbers.
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.
none
Type bool
Instrument.ETF
What is an ETF?
Instrument.Exchange outputs the description/definition of the current exchange for the current instrument.
none
An exchange object of the type "public enum exchanges"
Instrument.Exchange
An overview of various exchange: https://en.wikipedia.org/wiki/List_of_stock_exchanges
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.
None
Type DateTime
For instruments without an expiry date the returned value is set to DateTime.MaxValue(= 31.12.9999 23.59:59)
Instrument.Expiry
The expiry date (expiry) can also be seen within the Instrument Escort:
Instrument.GetCurrencyFactor returns a conversion factor that can be used to convert an instrument's currency to the account's currency.
Type Currencies
Type double
Instrument.GetCurrencyFactor(Currencies)
Common currencies are.B. AUD, CAD, EUR, GBP, JPY oder USD.
Instrument.InstrumentType outputs a type object of the trading instrument.
none
Object of the type "public enum instrument"
Instrument.InstrumentType
Potential values are: future, stock, index, currency, option, CFD and unknown.
The instrument type can also be viewed within the Instrument Escort:
Instrument.MainSector returns the main sector of the trading instrument.
none
String
Instrument.MainSector
The main sector is also visible in the instrument escort:
Instrument.MainSector returns the required margin of the trading instrument.
none
int
Instrument.Margin
Margin is also visible in the instrument escort:
Instrument.Name outputs the name/description of the trading instrument.
none
Type string
Instrument.Name
The instrument name can also be seen within the Instrument Escort:
Instrument.PointValue outputs the monetary value for a full point movement of the instrument.
none
double – point value
Instrument.PointValue
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:
The function Instrument.Round2TickSize rounds the supplied market price to the smallest value divisible by the tick size of the instrument.
double – market value
double
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.
Example of professional Formatting, Formatting of Numbers.
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.
none
Type string
Instrument.Symbol
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:
The tick size is the smallest measurable unit that a financial instrument can move. This is usually called 1 tick.
none
double
Instrument.TickSize or simply TickSize
Stock: 0.01 ES future: 0.25 EUR/USD: 0.00001
Examples of professional Formatting, Formatting of Numbers.
More infomation about
This function is especially useful when formatting the output of various instruments that need rounding. Also see and , .
Wikipedia:
There is no ETF type. ETFs are considered to be of the type "stock" – see .
See and .
The keyword is equivalent to Instrument.TickSize. Both information requests will produce the same value and are thus interchangeable.
See and .