Data Types

A script in ActFX can use the following Delphi data types:

 

Data Type

Description

Byte, Word, Integer, Longint, Cardinal

Integer

Boolean

Logical: YES/NO

Real, Single, Double, Extended, Currency

Floating

Char

Character

String

String

TDateTime

Date and/or Time

 

The script in ActFX also utilizes different types of objects. Overall there are 7 available object classes:

 

hmtoggle_plus1TInstrument

TInstrument is a class which can be used to store an instrument along with all of its properties.

In order to use an object from this class, you must declare it:

 

Var

Instrument : TInstrument;

 

The objects belonging to this class have 5 properties:

 

a) Name: String – the instrument name

b) Buy: Double – the Ask rate

c) Sell: Double – the Bid rate

d) PointSize: Double – the smallest rate change that a given dealing rate can make. Also known as a pip (for example, the PointSize of EURUSD is 0.0001).

e) Id: String – the number of instrument in the instrument list

 

Below is an example of using an object Instr from the TInstrument class.

 

Example:

Let's assume that the object Instr holds the instrument EURUSD. EURUSD is the first on the instrument list, the current rate is 1.4223/1.4228, and the script includes the following lines:

 

Var

Instr : TInstrument;

Number, Name : String;

Bid, Ask, PntSize : Double;

 

// The ways how an instrument can be assigned to the object will be described in the following chapters

 

Number := Instr.Id;

Name := Instr.Name;

Ask := Instr.Buy;

Bid := Instr.Sell;

PntSize := Instr.PointSize;

 

As a result we will get:

Number = 1

Name = EURUSD

Bid = 1.4223

Ask = 1.4228

PntSize = 0.0001

 

hmtoggle_plus1TAccount

TAccount is a class which can be used to store an account along with all of its properties.

In order to use an object from this class, you must declare it:

 

Var

Acc: TAccount;

 

The objects belonging to this class have 5 properties:

a) Id: String – the account number

b) Balance: Double – the account balance

c) Equity: Double – the account equity

d) UsedMargin: Double – the used margin

e) EquityLevel: Double – the equity level, % (Equity Level= Equity/Used Margin*100)

 

Below is an example of using an object Acc from the class TAccount.

 

Example:

Let's assume that the object Acc holds the account number 12434, with a $2000 balance, and a $2250 equity. The used margin is $500, and the equity level is 450%. The script includes the following lines:

 

Var

Acc : TAccount;

AccNum: String;

Balance, Equity, UsedM, EqLevel : Double;

 

// The ways how an account can be assigned to the object will be described in the following chapters

 

AccNum := Acc.Id;

Balance := Acc.Balance;

Equity := Acc.Equity;

UsedM := Acc.UsedMargin;

EqLevel := Acc.EquityLevel;

 

As a result we will get:

AccNum = 12434

Balance = 2000

Equity = 2250

UsedM =  500

EqLevel =  450

 

hmtoggle_plus1TOrder

TOrder is a class which can be used to store an order along with all of its properties.

In order to use an object from this class, you must declare it:

 

Var

Ordr : TOrder;

 

The objects belonging to this class have 7 properties:

a) Id: String – the ticket number of the order

b) Instrument: TInstrument– the instrument on which the order is placed

c) Account: TAccount – the account on which the order is placed

d) Tag: String he order tag, which can be used to mark an order in the script

e) Rate: Double – the order rate

f) BuySell: TBuySell – bsBuy or bsSell

g) OrderType: TOrderType – the type of order. There are 14 different types of orders:

1)otInit – a market order to open a position
2)otRejInit – a market order rejected by the dealer
3)otClose – a market order to close a position
4)otRejClose – an order to close a position rejected by the dealer
5)otEStop – an Entry Stop type of order
6)otELimit – an Entry Limit type order
7)otStop – a stop order on a position
8)otLimit – a limit order on a position
9)otMargin – a margin call order
10)otMinEquity –  an order to close the position due to the Equity declining below the Minimal Equity level
11)otInitFailed –  failed market order due to unsufficient usable margin
12)otEFailed – failed entry order due to unsufficient margin or margin call
13)otStopFailed – failed stop order on a position due to margin call
14)otLimitFailed – failed limit order on a position due to margin call

 

Please note that the Instrument property holds the data type TInstrument, and the Account property holds the data type TAccount. There are two ways to use this:

 

Example:

Let's assume that the object Ordr holds the order placed on the instrument EURUSD. EURUSD is the first on the instrument list, the current rate is 1.4223/1.4228), the account number is 32234 (with a $2000 balance, and a $2250 equity), the order tag is 'a123', and the order ticket is 988898.

 

Method 1:

The script includes the following lines:

 

Var

Acc : TAccount;

Ordr : TOrdr;

Instr : TInstrument;

Ticket, Tag : String;

Bid, Ask, Balance : Double;

 

// The ways how an order can be assigned to the object will be described in the following chapters

 

Ticket := Ordr.Id;

Tag := Ordr.Tag;

Instr := Ordr.Instrument;

Acc := Ordr.Account;

Ask := Instr.Buy;

Bid := Instr.Sell;

Balance := Acc.Balance;

 

As a result we will get:

Ticket = 988898

Tag = a123

Bid = 1.4223

Ask = 1.4228

Balance =  2000

 

As you can see, in order to get the current rate of the instrument on which the order is placed, we had to create a Tinstrument type object Instr and attach it to the Instrument property of the object Ordr. We had to do the same thing with the Account.

 

Method 2:

There is another way to use the information. In this case we do not need to create additional objects. For instance, if we need to get the Ask rate of the Instrument on which the order is placed, we can type the following line:

 

Ask := Ordr.Instrument.Buy;

 

In this case we need the following script:

 

Var

Ordr : TOrdr;

Ticket, Tag : string;

Ask, Bid, Balance : double;

 

// The ways how an order can be assigned to the object will be described in the following chapters

 

Ticket := Ordr.Id;

Tag := Ordr.Tag;

Instr := Ordr.Instrument;

Acc := Ordr.Account;

Ask := Ordr.Instrument.Buy;

Bid := Ordr.Instrument.Sell;

Balance := Ordr.Account.Balance;

 

We will get the same result as in the previous case:

Ticket = 988898

Tag = a123

Bid = 1.4223

Ask = 1.4228

Balance =  2000

 

hmtoggle_plus1TTrade

TTrade is a class which can be used to store an open position along with all of its properties.

In order to use an object from this class, you must declare it:

 

Var

OpenPos: TTrade;

 

The objects belonging to this class have 12 properties:

a) Id: String – the open position ticket

b) Instrument: TInstrument– the instrument on which the position is opened

c) Account: TAccount – the account on which the position is opened

d) Amount: Double – the number of lots

e) OpenRate: Double – the open rate

f) CloseRate: Double — the current close rate

g) Tag: String — the position tag

h) NetPL: Double — the NetP/L of the open position

i) LimitOrder: TOrder —  the limit on this position (if there is one)

j) StopOrder: TOrder — the stop on this position (if there is one)

k) BuySell: TBuySell – bsBuy or bsSell

l) StrategyId: String - the Id number of the strategy which opened the position.

 

Below is an example of using an object OpenPos from the class TTrade.

 

Example:

Let's assume that the object OpenPos holds a position with the following parameters:

1)Ticket = 12221
2)Instrument

 a) Id = 1

 b) Name = EURUSD

 c) Buy = 1.4223

d) Sell = 1.4228

3)Account

a) Id = 433334

b) Balance = 2000

c) Equity = 2200

4)Number of lots = 2
5)The open rate = 1.4225
6)The current close rate = 1.4228
6)Tag = ‘a123’
7)Predefined stop = 1.4200
8)Predefined Limit = 1.4300

 

The script includes the following lines:

 

Var

OpenPos : TTrade;

PosTicket, InstNum, InstName, AccNum, PosTag: String;;

Ask, Bid, Balance, Equity, PosAmount, Open, Close, Stop, Limit: double;

 

// The ways how a position can be assigned to the object will be described in the following chapters

 

PosTicket := OpenPos.Id;

InstNum := OpenPos.Instrument.Id;

InstName := OpenPos.Instrument.Name;

Ask := OpenPos.Instrument.Buy;

Bid := OpenPos.Instrument.Sell;

AccNum := OpenPos.Account.Id;

Balance := OpenPos.Account.Balance;

Equity := OpenPos.Account.Equity;

PosAmount := OpenPos.Amount;

Open := OpenPos.OpenRate;

Close := OpenPos.CloseRate;

PosTag := OpenPos.Tag;

Limit:=OpenPos.LimitOrder.Rate

Stop:=OpenPos.StopOrder.Rate

 

As a result we will get:

 

PosTicket = 12221

InstNum = 1

InstName = EURUSD

Bid = 1.4223

Ask = 1.4228

AccNum = 433334

Balance = 2000

Equity = 2200

PosAmount = 2

Open = 1.4225

Close = 1.4228

PosTag = a123

Limit = 1.4300

Stop = 1.4200

 

hmtoggle_plus1TTick

TTick is a class which can be used to store an individual tick from the chart along with all of its properties.

In order to use an object from this class, you must declare it:

 

Var

Tick : TTick;

 

The objects belonging to this class have 2 properties:

a) Time: Time – time of the tick

b) Rate: Double – the Bid rate

 

Below is an example of using an object Tick from the class TTick.

 

Example:

Let's assume that the object Tick holds a tick received on January 21, 2007 at 12:10:00. The tick rate was 1.4234, and the script includes the following lines:

 

Var

Tick : TTick

TickTime : Time;

Rate : double;

 

// The ways how a Tick can be assigned to the object will be described in the following chapters

 

TickTime := Tick.Time;

Rate := Tick.Rate;

 

As a result we will get:

 

TickTime = 12.01.2007 12:10:00

Rate = 1.4234

 

hmtoggle_plus1TCandle

TCandle is a class which can be used to store a candle from the chart along with all of its properties.

In order to use an object from this class, you must declare it:

 

Var

Candle : TCandle;

 

The objects belonging to this class have 5 properties:

a) Time: Time – time when the candle was opened

b) Open: Double – open rate

c) Close: Double – close rate

d) High: Double – the candle maximum value

e) Low: Double – the candle minimum value

f) Median: Double – the candle median value = (High+Low)/2

g) Typical: Double – the candle typical value = (High+Low+Close)/3

h) Weighted: Double – the candle weighted value = (High+Low+2*Close)/4

 

 

 

clip0704

 

 

Below is an example of using an object Candle from the class TCandle.

 

Example:

Let's assume that the object Candle holds a candle which was opened on January 21, 2007 at 12:10:00.  Open = 1.4230, Close = 1.4240, High = 1.4250, Low = 1.4210, and the program includes the following lines:

 

Var

Candle : TCandle;

CandTime : Time;

Open, Close, High, Low: Double;

 

// The ways how a candle can be assigned to the object will be described in the following chapters

 

CandTime := Candle.Time;

Open := Candle.Open;

Close := Candle.Close;

High := Candle.High;

Low := Candle.Low;

 

As a result we will get:

 

CandTime = 12.01.2007 12:10:00

Open = 1.4230

Close = 1.4240

High = 1.4250

Low = 1.4210

 

hmtoggle_plus1TStrategy

TStrategy is a class which can be used to store a user strategy along with its properties.

We can use only one object from this class inside the strategy (Strategy: TStrategy),

and we do not need to declare it.

The objects belonging to this class have 2 properties:

a) Caption: String;

b) Id: String;

 

Example:

Let's assume that the strategy id is 4665, and the the script is as follows:

 

const

StrategyName = 'MyStrategy';

 

var

Capt: String;

IdNum: String;

 

 

Capt := Strategy.Caption;

IdNum := Strategy.Id;

 

As a result we will get:

 

Capt = 'MyStrategy'

IdNum = 4665

 

Show/Hide Hidden Text