1) Formula script language

The Formula script language is a tool for writing formulas. It is a combination of syntactic rules and commands which define the formulas.

2) Formula of an indicator

The indicator’s formula is a line/lines that defines the indicator. Every line of the formula has to end with “;”. For instance: “R: C;”.

3) Writing a formula for an indicator

You can access the list of the indicator’s formulas by clicking Add/Remove overlay indicators and then More. The following window appears:

 

 

You can see all the main fields of indicators (namespaces): Basic, Extend, Native.

Choose the indicator you wish to change and press the Edit button. A new window will appear:

 

 

A personal indicator can be designed by right-clicking and choosing Add Formula Program. In the Name field you can choose a name for the new indicator. In the Code field you write the formula of the indicator. The Debug button allows examination of the syntax. Press it always before the Compile button. The Compile button converts the formula of the new indicator into a source code. Then press the Close button. A window appears, confirming the new formula. Press Yes. Thus, your indicator will be saved and added to the list of existing indicators in the platform. Close the rest of the windows by clicking the Close button. The new indicator can be added either below the chart or above it.

4) Creating a new indicator

The formula “DIFFERENCE: C - O;” creates an indicator with values (Close-Open).

5) Creating a new variable indicator

The equation “A: = (C + O) / 2; “ creates a variable indicator with values (Close-Open)/2. The variable indicators are not visible on the chart; they reflect transitional values and take a part when creating other indicators. For instance: “MM: C + A;” creates the indicator ММ, which consists of the variable indicator А and the Close values of the current market price.

6) Changing the colour of the indicator

The colour of the indicator changes when the formula has been edited. When creating a new indicator, its will use the default colour. In order to change the default colour, you have to add the following line to the formula “colorRed;” The formula of our indicator changes to: ”DIFFERENCE: C-O, colorRed;”. The colour might be set with its digital value, for instance: “DIFFERENCE: C-O, Color # FF0000;”. (The number #FF0000 is the hexadecimal equivalent to the Red colour).

 

Hexadecimal equivalents of main colors:

 

Number

Color

Name of the Color

Hexadecimal

1

 

Black

#000000

2

 

White

#FFFFFF

3

 

Green

#008000

4

 

Maroon

#800000

5

 

Olive

#808000

6

 

Navy

#000080

7

 

Purple

#800080

8

 

Gray

#808080

9

 

Yellow

#FFFF00

10

 

Lime

#00FF00

11

 

Aqua

#00FFFF

12

 

Fuchsia

#FF00FF

13

 

Silver

#C0C0C0

14

 

Red

#FF0000

15

 

Blue

#0000FF

16

 

Teal

#008080

17

 

no name

#FF9966

18

 

no name

#CC33FF

19

 

no name

#FF99FF

20

 

no name

#996633

21

 

no name

#009933

22

 

no name

#0099FF

 

How to turn an RGB colour into a hexadecimal colour?

R=
G=
B=
 

When you add an indicator with a specified colour in its formula, for instance, “MyIndicator: C+1, colorGreen;“, then you can’t change the colour of this indicator. It will always appear with the colour set as default in its formula.

 

7) Making a copy of the Quotes chart

You can make a copy of the chart by creating an indicator identical to the main chart. You need to insert the following code into the Code field:

 

“MIRROR: GETSTOCK (O, C, H, L);”

 

When you close the rest of the indicators and expand the main field to 50%, you get a mirror of the chart.

 

indicators

 

You can modify the code of the indicator to adjust your purpose:

 

   - “MIRROR: GETSTOCK(C,O,H,L);” – the formula creates an indicator in which the red candles become green and visa versa.

   - “MIRROR: GETSTOCK (O,C,H+1,L-1);” – the indicator has longer candle tales.

 

8) Table of the formula script language

You can make a copy of the chart by creating an indicator identical to the main chart. You need to insert the following code into the Code field:

 

 

Method Name

Method Description

Example

OPEN/CLOSE/HIGH/LOW/VOLUME/AMOUNT

CLOSE

Gets the instrument closing prices.

CLOSE

OPEN

Gets the instrument open prices.

OPEN

HIGH

Gets the instrument highest prices.

HIGH

LOW

Gets the instrument lowest prices.

LOW

VOLUME

Gets the instrument volume.

VOLUME

AMOUNT

Gets the instrument amount.

AMOUNT

C

Shortcut of CLOSE.

C

O

Shortcut of OPEN.

O

H

Shortcut of HIGH.

H

L

Shortcut of LOW.

L

V

Shortcut of VOLUME.

V

VOL

Shortcut of VOLUME.

VOL

Other basic data

DATACOUNT

Data count of current data array.

DATACOUNT

Time and date functions

DATE

This returns the date of format yymmdd , yy means the real year minus 1970, mm means month, dd means day.

DATE

DAY

This returns the day of the month.

DAY

HOUR

This returns the hour of the day.

HOUR

MINUTE

This returns the minute of the hour.

MINUTE

MONTH

This returns the month of the year. If today was July 15th, 2006, this function would return 7.

MONTH

TIME

Returns the time in format hh.mm.ss, where hh is hour, mm is minute, ss is second.

TIME

WEEK

Returns the week of the year.

WEEK

WEEKDAY

This returns a number that is equal to the day of the week.

WEEKDAY

YEAR

This function will return the value of the year.

YEAR

Reference functions

SUM (Data Array,N)

This function totals the values for Data Array over the last N number of records.

SUM(C,10)

COUNT (Data Array,N)

Shows the amount of the count of the last N values in the Data Array.

COUNT(C>O,10)

REF (DataArray,N)

This returns the value of Data Array on a previous or subsequent period. The time to be accessed is expressed by N.

REF(C,1)

MA (DataArray,N)

N days moving average line.

MA(C,10)

EMA (DataArray,N)

N days exp moving average line.

EMA(C,10)

SMA (DataArray,N)

N days simple moving average line.

SMA(C,10)

DMA (Data Array,N)

N days dynamic moving average line.

DMA(C,10)

HHV (DataArray,N)

Calculates the highest value of the Data array from the most recent N number of records.

HHV(C,10)

LLV (DataArray,N)

Calculates the lowest value of the Data array from the most recent N number of records.

LLV(REF(C,1),10)

HHVBARS (DataArray,N)

Looks at the last N number of records in Data Array. This function returns the number of periods that have passed since the highest value of those records examined. This function always includes the current period in its calculations.

HHVBARS(C,10)

LLVBARS (DataArray,N)

Looks at the last N number of records in Data Array. This function returns the number of periods that have passed since the lowest value of those records examined. This function always includes the current period in its calculations.

LLVBARS(C,10)

BARSCOUNT (DataArray)

 

BARSCOUNT(C,10)

SUMBARS (DataArray,N)

 

SUMBARS(C,10)

BARSLAST (DataArray)

 

BARSLAST(C)

BARSSINCE (DataArray)

 

BARSSINCE(C)

BACKSET (DataArray,N)

 

BACKSET(C,10)

FILTER (DataArray,N)

 

FILTER(C,10)

Logic functions

IF (Condition,

True DataArray,

False DataArray)

This is the basic decision making function. If Condition is tree, the result is whatever is in the True Data Array position. Otherwise it returns what is in the False Data Array position.

IF(C>O,H,L)

// if Close>Open return High otherwise return Low

BETWEEN(DataArray1,
DataArray2,DataArray3)

 

BETWEEN(C-O,2,3)

RANGE(DataArray1,

DataArray2,
DataArray3)

 

RANGE(C-O,1,2)

CROSS(DataArray1,

DataArray2)

 

CROSS(MA(C,5),MA(C,10))

LONGCROSS(DataArray1,

DataArray2,

N)

 

LONGCROSS(MA(C,10),MA(C,20),10)

NOT(DataArray)

 

NOT(C>O)

ISLASTBAR(DataArray)

 

ISLASTBAR(C)

EXIST(DataArray,N)

 

EXIST(C>O,N)

EVERY(DataArray,N)

 

EVERY(C,N)

LAST(DataArray,N)

 

LAST(C,10)

ISUP

Return 1 if C>O, Otherwise 0.

ISUP

ISDOWN

Return 1 if C<O, Otherwise 0.

ISDOWN

ISEQUAL

Return 1 if C=O, Otherwise 0.

ISEQUAL

Math functions 1

MAX(DataArray1,DataArray2)

This examines both values inserted for the Data Array and returns which ever of the two has the largest numerical value.

MAX(H-C,C-L)

MIN(DataArray1,DataArray2)

This examines both values inserted for the Data Array and returns which ever of the two has the smallest numerical value.

MIN(C-L,H-C)

ABS(DataArray)

This function returns the absolute value of the specified data array. The absolute value is equal to the value of the number without any positive or negative sign.

ABC(O-C)

FLOOR(DataArray)

The Floor function returns the highest integer that is lower that the smallest value in the data array.

FLOOR(C/O*1000)

CEILING(DataArray)

The Ceiling function returns the lowest integer that is greater that the largest value in the data array.

CEILING(C/O*1000)

INTPART(DataArray)

This will return only the non-fractional portion of Data Array. In other words, anything to the right of the decimal point is dropped.

INTPART(C)

MOD(DataArray1,DataArray2)

Calculates what is left after the Data Array1 is divided by the Data Array2.

MOD(DAY,5)

SGN(DataArray)

This function returns the sign of Data Array.

SGN(C-O)

REVERSE(DataArray)

This function multiplies the value of Data Array by negative one.

REVERSE(C-O)

Math functions 2

SIN(DataArray)

Calculates the geometric function Sine.

SIN(C)

COS(DataArray)

Calculates the geometric function Cosine.

COS(BARSSINCE(C))

TAN(DataArray)

Calculates TAN of the Data Array.

TAN(C)

ASIN(DataArray)

Calculates Arc sine of the Data Array.

ASIN(C)

ACOS(DataArray)

Calculates Arc Cosine of the Data Array

ACOS(C)

ATAN(DataArray)

This is trigonometric function dealing with the ratio between angles and the legs of a right triangle.

ATAN(C)

LOG10(DataArray)

This function calculated 10 based logarithm of Data Array.

LOG10(C)

LN(Data Array)

This function calculated the natural logarithm of Data Array.

LN(C)

EXP(DataArray)

Calculates the mathematical constant e rose to the Data Array power.

EXP(C)

SQRT(DataArray)

This calculates the square root of Data Array.

SQRT(C)

SQR(DataArray)

Calculates the square of Data Array.

SQR(C)

POWER(DataArray,N)

This calculates the value of Data Array raise to a specified N.

POWER(C,3)

POW(DataArray)

Shortcut of POWER.

POW(C,3)

Statistics functions

STD(DataArray,N)

This calculates the value of the Standard Deviation indicator.

STD(C,10)

STDP(DataArray,N)

 

STDP(C,10)

VAR(DataArray,N)

This function examines the Data Array and calculates the statistical variance over N number of records.

VAR(C,10)

VARP(DataArray,N)

 

VARP(C,10)

AVEDEV(DataArray,N)

 

AVEDEV(C,10)

DEVSQ(DataArray,N)

 

DEVSQ(C,10)

FORCAST(DataArray,N)

 

FORCAST(C,10)

SLOPE(DataArray,N)

 

SLOPE(C,10)

CORR(DataArray1,

DataArray2,

N)

 

CORR(C,H,10)

Index function

ZIG(DataArray,N)

This calculates the value of the Zig Zag indicator on the Data Array specified.

ZIG(C,10)

PEAK(DataArray,N,M)

 

PEAK(C,20,10)

PEAKBARS(DataArray,N,M)

 

PEAKBARS(C,20,10)

TROUGH(DataArray,N,M)

 

PEAKBARS(C,20,10)

TROUGHBARS(DataArray,N,M)

 

TROUGHBARS(C,20,10)

SAR(N,STEP,MAXP)

 

SAR(10,1,2)

SARTURN(N,STEP,MAXP)

 

SARTURN(10,1,2)

String functions

EXCHANGE

Return current market name.

STKMARKET

CODE

Return current instrument label.

STKLABEL

NAME

Return current instrument name.

STKNAME

STKINBLOCK(string)

Return if the instrument belongs to the block.

STKINBLOCK(“COMPUTER”)

STRCMP(string1,string2)

Compare two string string1 and string2

STRCMP(CODE,”MSFT”)

STRNCMP(string1,string2,N)

Compare first N chars of string1 and string2.

STRNCMP(CODE,”MS”,2)

Draw functions

DRAWTEXT (Condition,

DataArray,

s)

Draw text at DataArray when Condition is true.

DRAWTEXT(ISUP,C-1,”ISUP”)

DRAWNUMBER(Condition,

DataArray1,
DataArray2,

Precision)

Draw DataArray1 at DataArray2 when Condition is true.

DRAWNUMBER(ISDOWN,C+1,L,5)

DRAWICON(Condition,

DataArray,

IconIndex)

Draw Icon at DataArray when Condition is true.

DRAWICON(ISUP,C-1,2)

POLYLINE(Condition,DataArray)

Draw Poly line at DataArray when Condition is true.

POLYLINE(ISUP,C)

DRAWLINE(Condition1,

DataArray1,
Condition2,

DataArray2,

Expand)

Draw Line start at Condition1, DataArray1, end with Condition2, DataArray2.

DRAWLINE(ISUP,C,ISDOWN,O,0)

STICKLINE (Condition,

DataArray1,

DataArray2, Width,

Empty)

Draw Stick line at DataArray1 and DataArray2 when Condition is true.

STICKLINE(ISUP,C,O,2,0)

FILLRGN (Condition,

DataArray1,

DataArray2)

Fill region at DataArray1 and DataArray2 when Condition is true.

FILLRGN(ISUP,C,O)

PARTLINE (Condition,

DataArray1)

Draws partial line at DataArray1 when Condition is true.

PARTLINE(ISUP,C)

VERTLINE (DataArray1)

Draws vertical line at DataArray1.

VERTLINE(DAY==1)

GETSTOCK (O,C,H,L)

Draws candle with O,C,H,L.

GETSTOCK(O,C,H+1,L-1)

STOCK

Draws candle of current instrument.

STOCK

Advanced functions

STKINDI(StkLabel,IndexName),
FML(StkLabel,IndexName)

Get another instrument's indicator of the current market.

FML(“NTES”,”C”)

Operators

+ - * /

 

C+O-H*L/V

> < >= <= == !=

 

(C>O)+(H-O)>=(O-C)

& | ^ % ! ~ ++ --

 

C>10 & C<11