Navigation:  5. Using Charts > Time Frame Charts >

 

Indicator Script Language

Previous pageReturn to chapter overviewNext page
The below table shows all basic method supported by formula script language.
Show line name before ":" . For example DIFF:C-O , means formula line DIFF will show in the chart.
Don't show line name before ":=". For example A:=(C+O)/2, means formula line A will not show in the chart. It's an intermediate variable.
Separate script lines ";".
Supported operators : + - * / > < >= <= = = ! = & | ^ % ! ~ ++ --

 

 

 

More than 100 basic methods can be used in formula script language.

Method

Parameter

Return

Description

1.Functions

SETNAME(f,Name)

f:Data Array
Name:String

 

Set formula line name. should be start with @.

SETNAME(Name,ShowParam)

Name:String
ShowParam:TRUE or FALSE

 

Set formula line name, should be start with @. ShowParam : show parameters in formula name

SETNAME(Name)

Name:String

 

Set formula name. should be start with @.

SETTEXTVISIBLE(f,Visible)

f:Data Array
Visible:TRUE or FALSE

 

Set formula line name visibility. should be start with @.

SETVALUETEXTMODE(Mode)

Mode:String

 

Set formula value text mode, the posible value is None,TextOnly,ValueOnly,Both. should be start with @.

SETTEXTVISIBLE(Visible)

Visible:TRUE or FALSE

 

Set formula name visibility. should be start with @.

SETATTR(f,s)

f:Data Array
s:String

 

Set attribute of the formula. should be start with @.

SHOWYGRIDLINE(Visible)

Visible:TRUE or FALSE

 

false if hide y-axis grid line. should be start with @.

SETHLINE(ss)

ss:

 

Custom horizontal line, e.g. 30,50,70. should be start with @.

SETYMINMAX(MinY,MaxY)

MinY:Number
MaxY:Number

 

Set min,max value of Y-axis, e.g. 0,100. should be start with @.

2.Basic Data

ASKPRICE(N)

N:Number

Data Array

Get Nth ask price

ASKVOL(N)

N:Number

Data Array

Get Nth ask volume

BIDPRICE(N)

N:Number

Data Array

Get Nth bid price

BIDVOL(N)

N:Number

Data Array

Get Nth bid volume

BUYVOL(N)

N:Number

Data Array

Get Nth buy volume

SELLVOL(N)

N:Number

Data Array

Get Nth sell volume

ORGDATA(DataName)

DataName:String

Data Array

Reference data from data provider. For example : OrgData('CLOSE')

EXTDATA(N)

N:Number

Data Array

Get Nth extra data, can be defined by data provider

CLOSE

 

Data Array

Get the stock close price

C

 

Data Array

Shortcut of CLOSE

OPEN

 

Data Array

Get the stock open price

O

 

Data Array

Shortcut of OPEN

HIGH

 

Data Array

Get the stock highest price

H

 

Data Array

Shortcut of HIGH

LOW

 

Data Array

Get the stock lowest price

L

 

Data Array

Shortcut of LOW

VOLUME

 

Data Array

Get the stock VOLUME

VOL

 

Data Array

Shortcut of VOLUME

V

 

Data Array

Shortcut of VOLUME

AMOUNT

 

Data Array

Get the stock amount

ADVANCE

 

Data Array

Get rising numbers of current exchange

DECLINE

 

Data Array

Get falling numbers of current exchange

ISBUYORDER

 

Data Array

Is buy order,should be supported by data provider

3.Extra Basic Data

FINANCE(N)

N:Number

Number

Basic finance data , should be supported by data provider, FINANCE1...FINANCE100

DYNAINFO(N)

N:Number

Number

Dynamic information, should be supported by data provider,DYNAINFO1..DYNAINFO100

VOLUNIT

 

Number

Volume unit 100 or 1000, should be supported by data provider

CAPITAL

 

Number

Capital of current stock, should be supported by data provider

DATACOUNT

 

Number

Bars count of current data provider

4.Date & Time

NEARESTTIME(D,T)

D:Number
T:Number

Data Array

return 1 if the trading date is near or equal to (D,T), D :Year*10000+Month*100+Day, T: Hour*10000+Minute*100+Second

DATEDIFF(f1,f2)

f1:Data Array
f2:Data Array

Data Array

Days between the two data arrays

DATE

 

Data Array

Get date array, the format is Year*10000+Month*100+Day

OLEDATE

 

Data Array

Get ole date array

DOUBLEDATE

 

Data Array

Get double date array

LASTDOUBLEDATE

 

Number

Return last double date

DAY

 

Data Array

Get day array.

HOUR

 

Data Array

Get hour array.

MINUTE

 

Data Array

Get minute array.

MONTH

 

Data Array

Get month array.

TIME

 

Data Array

Get time array,the format is Hour*10000+Minute*100+Second

WEEK

 

Data Array

Get week array,0..6, 0 means Sunday,6 means Saturday

WEEKDAY

 

Data Array

Get week array,0..6, 0 means Sunday,6 means Saturday

YEAR

 

Data Array

Get year array

5.Reference functions

MUL(f)

f:Data Array

Data Array

Multiple from the first bar

SUM(f,N)

f:Data Array
N:Number

Data Array

Sum last N days value

SUM(f)

f:Data Array

Data Array

Sum from the first bar

COUNT(f,N)

f:Data Array
N:Number

Data Array

True count of last N days

REF(f,N)

f:Data Array
N:Number

Data Array

Reference value of N days before

EXTEND(f)

f:Data Array

Data Array

Extend last value to last bar

MA(f,N)

f:Data Array
N:Number

Data Array

N days moving average

EMA(f,N)

f:Data Array
N:Number

Data Array

N days exponential moving average

SMA(f,N,M)

f:Data Array
N:Number
M:Number

Data Array

Simple moving average, equal to DMA(f,M/N), M<N

DMA(f,A)

f:Data Array
A:Number

Data Array

Dynamic moving average, D[i] = D[i]*A+D[i-1]*(1-A), 0<A<1

HHV(f,N)

f:Data Array
N:Number

Data Array

N days highest value

HHV(f)

f:Data Array

Data Array

Highest value

LLV(f,N)

f:Data Array
N:Number

Data Array

N days lowest value

LLV(f)

f:Data Array

Data Array

Lowest value

HHVBARS(f,N)

f:Data Array
N:Number

Data Array

N days highest value bars count

LLVBARS(f,N)

f:Data Array
N:Number

Data Array

N days lowest value bars count

BARSCOUNT(f)

f:Data Array

Data Array

Bars count

SUMBARS(f,N)

f:Data Array
N:Number

Data Array

Bars count when sum up to N

BARSLAST(f)

f:Data Array

Data Array

Bars count when value > 0

BARSSINCE(Cond)

Cond:Data Array

Data Array

Bars count since first Cond>0

BACKSET(Cond,f,N)

Cond:Data Array
f:Data Array
N:Number

Data Array

Backset N bars to f when Cond>0

BACKSET(Cond,N)

Cond:Data Array
N:Number

Data Array

Backset N bars to 1 when Cond>0

FILTER(Cond,N)

Cond:Data Array
N:Number

Data Array

Set next N bars to 0 when Cond>0

TOVALUE(Cond,f,Percent,ValueType)

Cond:Data Array
f:Data Array
Percent:Number
ValueType:Number

Data Array

f by the Percent between every two COND.ValueType,0:ShowValue,1:Up Percent, 2:Down Percent

TOVALUE(Cond,f,Percent)

Cond:Data Array
f:Data Array
Percent:Number

Data Array

f by the Percent between every two COND.

6.Logic functions

IF(f1,f2,f3)

f1:Data Array
f2:Data Array
f3:Data Array

Data Array

If f1>0 return f2 , otherwise return f3

BETWEEN(f1,f2,f3)

f1:Data Array
f2:Data Array
f3:Data Array

Data Array

If f3>f1>f2 or f2>f1>f3 return 1, otherwise return 0

NEAR(f1,f2,P)

f1:Data Array
f2:Data Array
P:Number

Data Array

f1 is near f2 in percent of P

RANGE(f1,f2,f3)

f1:Data Array
f2:Data Array
f3:Data Array

Data Array

If f1 between f2 and f3 return 1, otherwise return 0

CROSS(f1,f2)

f1:Data Array
f2:Data Array

Data Array

If f1 cross f2 from below return 1, otherwise return 0

LONGCROSS(f1,f2,N)

f1:Data Array
f2:Data Array
N:Number

Data Array

If f1 cross f2 from below and the cross last N bars return 1, otherwise return 0

NOT(f1)

f1:Data Array

Data Array

If f1==0 return 1 , otherwise return 0

ISLASTVALUE(f)

f:Data Array

Data Array

Set last bar has values to 1 other bars to 0

EXIST(f,N)

f:Data Array
N:Number

Data Array

If exist non-zero value in last N bars return 1 otherwise return 0

EVERY(f,N)

f:Data Array
N:Number

Data Array

If exist zero value in last N bars return 0 otherwise return 1

LAST(f,A,B)

f:Data Array
A:Number
B:Number

Data Array

If exist zero value in last A bars to B bars return 0 otherwise return 1

ISLASTBAR

 

Data Array

Set last bar to 1 other bars to 0

ISLASTDAY

 

Data Array

return 1 if current bar belongs to last day

ISUP

 

Data Array

If close value > open value return 1 otherwise return 0

ISDOWN

 

Data Array

If close value < open value return 1 otherwise return 0

ISEQUAL

 

Data Array

If close value = open value return 1 otherwise return 0

7.Basic Math functions

MAX(fds)

fds:

Data Array

Maximum values

MIN(fds)

fds:

Data Array

Minimum values

ABS(d)

d:Number

Number

Absolute value, will return double.

ABS(f)

f:Data Array

Data Array

Absolute values

FLOOR(f)

f:Data Array

Data Array

The smallest whole number greater than or equal to f

CEILING(f)

f:Data Array

Data Array

The smallest whole number greater than or equal to f

ROUND(f,decimals)

f:Data Array
decimals:Number

Data Array

Returns the number nearest the specified value

ROUND(f)

f:Data Array

Data Array

Returns the number nearest the specified value

INTPART(f)

f:Data Array

Data Array

The integer part of the value

MOD(f1,f2)

f1:Data Array
f2:Data Array

Data Array

Equal to f1 % f2

SGN(f)

f:Data Array

Data Array

The sign of value

REVERSE(f)

f:Data Array

Data Array

Equal to -f

8.Extra Math functions

SIN(f)

f:Data Array

Data Array

Sin

COS(f)

f:Data Array

Data Array

Cos

TAN(f)

f:Data Array

Data Array

Tag

ASIN(f)

f:Data Array

Data Array

Arc Sin

ACOS(f)

f:Data Array

Data Array

Arc Cos

ATAN(f)

f:Data Array

Data Array

Arc Tan

LOG10(f)

f:Data Array

Data Array

10 based Log

LOG(f)

f:Data Array

Data Array

10 based Log

LOG(f,N)

f:Data Array
N:Number

Data Array

N based Log

LN(f)

f:Data Array

Data Array

e based Log

EXP(f)

f:Data Array

Data Array

e raised to the specified power

SQRT(f)

f:Data Array

Data Array

Square root of the value

SQRT(d)

d:Number

Number

Return square root of d

SQR(f)

f:Data Array

Data Array

Square of the value

POWER(f,N)

f:Data Array
N:Number

Data Array

N Power of the value

POW(f,N)

f:Data Array
N:Number

Data Array

N Power of the value

9.Statistics functions

STD(f,N)

f:Data Array
N:Number

Data Array

N days standard value

STDP(f,N)

f:Data Array
N:Number

Data Array

N days StdP value

VAR(f,N)

f:Data Array
N:Number

Data Array

N days Variant value

VARP(f,N)

f:Data Array
N:Number

Data Array

N days VarP value

AVEDEV(f,N)

f:Data Array
N:Number

Data Array

N days average value

DEVSQ(f,N)

f:Data Array
N:Number

Data Array

N days DevSQ value

LR(f,N,Start)

f:Data Array
N:Number
Start:Number

Data Array

N days Linear Regression

MAXVALUE(f)

f:Data Array

Number

Maximum value of f

MINVALUE(f)

f:Data Array

Number

Minimum value of f

LR(f,N)

f:Data Array
N:Number

Data Array

N days Linear Regression

FORCAST(f,N)

f:Data Array
N:Number

Data Array

N days linear regression fore cast

SLOPE(f,N)

f:Data Array
N:Number

Data Array

N days linear regression slope

CORR(f1,f2,N)

f1:Data Array
f2:Data Array
N:Number

Data Array

N days correlation factor between f1 and f2

A.Index functions

ZIG(fMin,fMax,N)

fMin:Data Array
fMax:Data Array
N:Number

Data Array

N days Zig Zag

ZIG(f,N)

f:Data Array
N:Number

Data Array

N days Zig Zag

ZIG(N)

N:Number

Data Array

N days Zig Zag

ZIGP(fMin,fMax,N)

fMin:Data Array
fMax:Data Array
N:Number

Data Array

N days Zig Zag percent value

ZIGP(f,N)

f:Data Array
N:Number

Data Array

N days Zig Zag percent value

ZIGP(N)

N:Number

Data Array

N days Zig Zag percent value

VALUEWHEN(Expr,f,N)

Expr:Data Array
f:Data Array
N:Number

Data Array

Count Expr was true N times and reports the value off

VALUEWHENBARS(Expr,N)

Expr:Data Array
N:Number

Data Array

Count Expr was true N times and reports the bars count

FINDPEAK(f)

f:Data Array

Data Array

Find Peak

FINDPEAK(fMin,fMax,N)

fMin:Data Array
fMax:Data Array
N:Number

Data Array

Find Peak based on Zig(N)

FINDPEAK(f,N)

f:Data Array
N:Number

Data Array

Find Peak based on Zig(N)

FINDPEAK(N)

N:Number

Data Array

Find Peak based on Zig(N)

FINDTROUGH(f)

f:Data Array

Data Array

Find Trough

FINDTROUGH(fMin,fMax,N)

fMin:Data Array
fMax:Data Array
N:Number

Data Array

Find Trough based on Zig(N)

FINDTROUGH(f,N)

f:Data Array
N:Number

Data Array

Find Trough based on Zig(N)

FINDTROUGH(N)

N:Number

Data Array

Find Trough based on Zig(N)

PEAK(fMin,fMax,N,M)

fMin:Data Array
fMax:Data Array
N:Number
M:Number

Data Array

Mth Peak line based on Zig(N)

PEAK(f,N,M)

f:Data Array
N:Number
M:Number

Data Array

Mth Peak line based on Zig(N)

PEAK(f,N)

f:Data Array
N:Number

Data Array

Peak line based on Zig(N)

PEAK(N,M)

N:Number
M:Number

Data Array

Peak line based on Zig(N)

PEAK(N)

N:Number

Data Array

Peak line based on Zig(N)

PEAKBARS(fMin,fMax,N,M)

fMin:Data Array
fMax:Data Array
N:Number
M:Number

Data Array

Mth Peak bars based on Zig(N)

PEAKBARS(f,N,M)

f:Data Array
N:Number
M:Number

Data Array

Mth Peak bars based on Zig(N)

PEAKBARS(f,N)

f:Data Array
N:Number

Data Array

Peak bars based on Zig(N)

PEAKBARS(N,M)

N:Number
M:Number

Data Array

Peak bars based on Zig(N)

PEAKBARS(N)

N:Number

Data Array

Peak bars based on Zig(N)

PEAKBARS(K,N,M)

K:Number
N:Number
M:Number

Data Array

Mth Peak bars based on Zig(N)

TROUGH(fMin,fMax,N,M)

fMin:Data Array
fMax:Data Array
N:Number
M:Number

Data Array

Mth trough line based on Zig(N)

TROUGH(f,N,M)

f:Data Array
N:Number
M:Number

Data Array

Mth trough line based on Zig(N)

TROUGH(f,N)

f:Data Array
N:Number

Data Array

Trough line based on Zig(N)

TROUGH(N,M)

N:Number
M:Number

Data Array

Mth trough line based on Zig(N)

TROUGH(N)

N:Number

Data Array

Trough line based on Zig(N)

TROUGH(K,N,M)

K:Number
N:Number
M:Number

Data Array

Mth trough line based on Zig(N)

TROUGHBARS(fMin,fMax,N,M)

fMin:Data Array
fMax:Data Array
N:Number
M:Number

Data Array

Mth trough bars based on Zig(N)

TROUGHBARS(f,N,M)

f:Data Array
N:Number
M:Number

Data Array

Mth trough bars based on Zig(N)

TROUGHBARS(N,M)

N:Number
M:Number

Data Array

Mth trough bars based on Zig(N)

TROUGHBARS(N)

N:Number

Data Array

Mth trough bars based on Zig(N)

TROUGHBARS(K,N,M)

K:Number
N:Number
M:Number

Data Array

Mth trough bars based on Zig(N)

SAR(N,STEP,MAXP)

N:Number
STEP:Number
MAXP:Number

Data Array

Sar,N is the first bar to calculate sar

SAR(STEP,MAXP)

STEP:Number
MAXP:Number

Data Array

Sar

SARTURN(N,STEP,MAXP)

N:Number
STEP:Number
MAXP:Number

Data Array

Sar turns, 0 ,1 or -1

B.String functions

STRCMP(s1,s2)

s1:String
s2:String

Data Array

Compare two strings

STRNCMP(s1,s2,N)

s1:String
s2:String
N:Number

Data Array

Compare N chars of two strings

INDEXOF(s1,s2)

s1:String
s2:String

Data Array

return the first occurrence of s2 in s1

CONTAIN(s1,s2)

s1:String
s2:String

Data Array

return 1 if s1 contains s2, otherwise return 0.

IF(Cond,s1,s2)

Cond:Data Array
s1:String
s2:String

String

return s1 if Cond is true, otherwise return s2.

EXCHANGE

 

String

Return current exchange, should be supported by data provider

STKMARKET

 

String

Return current exchange, should be supported by data provider

CODE

 

String

Return Stock Symbol

STKLABEL

 

String

Return Stock Symbol

SYMBOL

 

String

Return Stock Symbol

STOCKNAME

 

String

Return Stock Name

STKNAME

 

String

Return Stock Name

C.Draw functions

DRAWTEXT(Cond,f,Text,fds)

Cond:Data Array
f:Data Array
Text:String
fds:

Data Array

Draw Text on f when Cond is True

DRAWTEXT(Bar,f,Text,fds)

Bar:Number
f:Data Array
Text:String
fds:

Data Array

Draw Text on f on Bar

DRAWNUMBER(Cond,Price,Number,Format)

Cond:Data Array
Price:Data Array
Number:Data Array
Format:String

Data Array

Draw Number on Price when Cond is True

DRAWICON(Cond,Price,ImageName)

Cond:Data Array
Price:Data Array
ImageName:String

Data Array

Draw Image on f when Cond is True

POLYLINE(Cond,Price)

Cond:Data Array
Price:Data Array

Data Array

Poly line,The point was defined by f when Cond is True

DRAWLINE(Cond,Price,Cond2,Price2,Expand)

Cond:Data Array
Price:Data Array
Cond2:Data Array
Price2:Data Array
Expand:Number

Data Array

Draw line from Price when Cond is True to Price2 when Cond2 is True

DRAWLINE(Bar1,Price1,Bar2,Price2,Expand)

Bar1:Number
Price1:Number
Bar2:Number
Price2:Number
Expand:Number

Data Array

Draw line from (Bar1,Price1) to (Bar2,Price2)

STICKLINE(Cond,Price,Price2,Width,Empty)

Cond:Data Array
Price:Data Array
Price2:Data Array
Width:Number
Empty:Number

Data Array

Draw stick line from Price to Price2 when Cond is True

STICKLINE(Cond,Price,Price2)

Cond:Data Array
Price:Data Array
Price2:Data Array

Data Array

Draw stick line from Price to Price2 when Cond is True

FILLRGN(Cond,Price,Price2)

Cond:Data Array
Price:Data Array
Price2:Data Array

Data Array

Fill region Price to Price2 when Cond is True

FILLAREA(f1)

f1:Data Array

Data Array

Fill area below f1

PARTLINE(Cond,f)

Cond:Data Array
f:Data Array

Data Array

Draw partial line

VERTLINE(f)

f:Data Array

Data Array

Draw vertical line

GETSTOCK(fO,fC,fH,fL)

fO:Data Array
fC:Data Array
fH:Data Array
fL:Data Array

Data Array

Draw stock bar based on fO,fC,fH,fL

STOCK

 

Data Array

Draw stock bar based on O,C,H,L

D.Advanced functions

FML(Symbol,FormulaName,Cycle)

Symbol:String
FormulaName:String
Cycle:String

Data Array

Reference other formula with cycle. For example : FML('MSFT','MACD[DIFF]','WEEK2')

FML(Symbol,FormulaName)

Symbol:String
FormulaName:String

Data Array

Reference other formula. For example : FML('MSFT','MACD[DIFF]')

FML(FormulaName)

FormulaName:String

Data Array

Reference other formula. For example : FML('MACD[DIFF]')

DATE2BAR(Date)

Date:String

Number

Convert string date to bar index,Date format is yyyy-MM-dd

E.Indicator functions

ATR(N)

N:Number

Data Array

N days average true range

 

 

©Estuary Solutions (www.estuarysolutions.com), All rights reserved.