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:
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:
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:
As a result we will get: Number = 1 Name = EURUSD Bid = 1.4223 Ask = 1.4228 PntSize = 0.0001 |
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:
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:
As a result we will get: AccNum = 12434 Balance = 2000 Equity = 2250 UsedM = 500 EqLevel = 450 |
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:
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:
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:
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:
In this case we need the following script:
We will get the same result as in the previous case: Ticket = 988898 Tag = a123 Bid = 1.4223 Ask = 1.4228 Balance = 2000 |
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:
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:
a) Id = 1 b) Name = EURUSD c) Buy = 1.4223 d) Sell = 1.4228
a) Id = 433334 b) Balance = 2000 c) Equity = 2200
The script includes the following lines:
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 |
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:
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:
As a result we will get:
TickTime = 12.01.2007 12:10:00 Rate = 1.4234 |
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:
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
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:
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 |
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:
As a result we will get:
Capt = 'MyStrategy' IdNum = 4665
|