You can use message notifications in your strategies. For instance, you may want to create a strategy that will instead of actively trading work as an advisor, notifying you about the right time to perform transactions. To do this, use the function ShowMessage(const s: String).
Example:
You need to get a message ‘Time to buy EURUSD’ every time when the difference between the open and the close price of the last finished candle is bigger than 20 points. You need the following lines:
|
You can use sound notifications in your strategies. For instance, you can write a strategy that will play an audio file every time some event takes place. To do this, use the function PlaySound(const FileName: String).
Example:
You want to hear a notification every time when the rate becomes higher than 1.5000. You need the following lines:
As a result, the audio file HighRate.wav from the directory E:\MySounds will be played. Note: 1) The Silent Mode in the WinClient settings should be disabled. Otherwise you will not hear any sounds. 2) The directory and file names should contain only Latin letters. 3) The file should be in the .wav format. |
Function |
Description |
function Sqr(const X: Double): Double |
Square |
function Max(const A, B: Double): Double |
The greater of the two numbers |
function Min(const A, B: Double): Double |
The lesser of the two numbers |
function Round(e: Extended): Integer |
Rounds to the nearest integer |
function Trunc(e: Extended): Integer |
Truncates the fractional part |
function Int(e: Extended): Integer |
Returns the integer part of the number |
function Frac(X: Extended): Extended |
Returns the fractional part |
function Sqrt(e: Extended): Extended |
Square root |
function Abs(e: Extended): Extended |
Absolute value |
function Sin(e: Extended): Extended |
Sine |
function Cos(e: Extended): Extended |
Cosine |
function ArcTan(X: Extended): Extended |
Arctangent |
function Tan(X: Extended): Extended |
Tangent |
function Exp(X: Extended): Extended |
Exponential |
function Ln(X: Extended): Extended |
Natural logarithm |
function Pi: Extended |
Pi |
|
|
|
procedure Inc(var i: Integer; incr: Integer = 1) |
Increment |
procedure Dec(var i: Integer; decr: Integer = 1) |
Decrement |
procedure RaiseException(Param: String) |
Generates error message |
procedure Randomize |
Initializes the random numbers generator |
function Random: Extended |
Generates a random number in the range between 0 and 1 |
function ValidInt(cInt: String): Boolean |
Validates an integer |
function ValidFloat(cFlt: String): Boolean |
Validates a fractional number |
function ValidDate(cDate: String): Boolean |
Validates a date |
TStringList class objects are used to save and load data to/from a .txt file. In order to create such an object, use the method TStringList.Create.
Example:
This object has 5 properties: a) Count: Integer – the number of strings in the list b) Names[ ]: String – the name at a given index in the list
There is a dual approach to store individual strings in a file. Each string can be stored as simple text (string), or if it contains the equals sign ('='), it can be treated as a name/value pair. The text on the left of the equals sign is regarded as a name, and the text on the right is regarded as a value. This concept provides an alternative way to refer to a particular value. The values property returns the value for a given name, therefore it is not necessary to know the index of the string. You can create a name/value string by simply assigning some value to some name.
Example:
If the name 'Amount' is already present in the list, the corresponding value will be changed to 5. If there is no such name, a new string will be appended to the end of the list.
Example:
Let us create a name/value pair when a position is opened. We will store the position ticket # with the name 'Trade'. We will also output this information into the log.
You can use the following methods when working with this object:
|