WinTrend: online trading software

Skip Navigation LinksDocumentation > Using Scripting Language > Scripting Language

Formula Scripting Guide

Below table shows all basic method supported by formula script language:

1. Show line name before ":". For example DIFF:C-O, formula line DIFF will show in the chart.

2. Don't show line name before ":=". For example A:=(C+O)/2, formula line A will not show in the chart. It's an intermedial variant.

3. Formula line seperate by ";".

5. Supported operators : '+', '-', '*', '/', '>', '<', '>=', '<=', '==', '!=', '&', '|', '^', '%', '!', '~', '++', '--'

6. $AAA equals to ORGDATA(AAA)

7. "MACD[DIFF]#WEEK2" equals to FML('MACD[DIFF]#WEEK2')


100+ basic method can be used in formula script language:

Category Method Parameter Return Description
1        
1.Functions SETNAME(f,Name) f:Data Array
Name:String
  Set formula line name. should be start with @.
1.Functions SETNAME(Name,ShowParam) Name:String
ShowParam:TRUE or FALSE
  Set formula line name, should be start with @. ShowParam : show parameters in formula name
1.Functions SETNAME(Name) Name:String
  Set formula name. should be start with @.
1.Functions SETTEXTVISIBLE(f,Visible) f:Data Array
Visible:TRUE or FALSE
  Set formula line name visibility. should be start with @.
1.Functions SETVALUETEXTMODE(Mode) Mode:String
  Set formula value text mode, the posible value is None,TextOnly,ValueOnly,Both. should be start with @.
1.Functions SETTEXTVISIBLE(Visible) Visible:TRUE or FALSE
  Set formula name visibility. should be start with @.
1.Functions SETATTR(f,s) f:Data Array
s:String
  Set attribute of the formula. should be start with @.
1.Functions SHOWYGRIDLINE(Visible) Visible:TRUE or FALSE
  false if hide y-axis grid line. should be start with @.
1.Functions SETHLINE(ss) ss:
  Custom horizontal line, e.g. 30,50,70. should be start with @.
1.Functions SETYMINMAX(MinY,MaxY) MinY:Number
MaxY:Number
  Set min,max value of Y-axis, e.g. 0,100. should be start with @.
2        
2.Basic Data ASKPRICE(N) N:Number
Data Array Get Nth ask price
2.Basic Data ASKVOL(N) N:Number
Data Array Get Nth ask volume
2.Basic Data BIDPRICE(N) N:Number
Data Array Get Nth bid price
2.Basic Data BIDVOL(N) N:Number
Data Array Get Nth bid volume
2.Basic Data BUYVOL(N) N:Number
Data Array Get Nth buy volume
2.Basic Data SELLVOL(N) N:Number
Data Array Get Nth sell volume
2.Basic Data ORGDATA(DataName) DataName:String
Data Array Reference data from data provider. For example : OrgData('CLOSE')
2.Basic Data EXTDATA(N) N:Number
Data Array Get Nth extra data, can be defined by data provider
2.Basic Data CLOSE   Data Array Get the stock close price
2.Basic Data C   Data Array Shortcut of CLOSE
2.Basic Data OPEN   Data Array Get the stock open price
2.Basic Data O   Data Array Shortcut of OPEN
2.Basic Data HIGH   Data Array Get the stock highest price
2.Basic Data H   Data Array Shortcut of HIGH
2.Basic Data LOW   Data Array Get the stock lowest price
2.Basic Data L   Data Array Shortcut of LOW
2.Basic Data VOLUME   Data Array Get the stock VOLUME
2.Basic Data VOL   Data Array Shortcut of VOLUME
2.Basic Data V   Data Array Shortcut of VOLUME
2.Basic Data AMOUNT   Data Array Get the stock amount
2.Basic Data ADVANCE   Data Array Get rising numbers of current exchange
2.Basic Data DECLINE   Data Array Get falling numbers of current exchange
2.Basic Data ISBUYORDER   Data Array Is buy order,should be supported by data provider
3        
3.Extra Basic Data FINANCE(N) N:Number
Number Basic finance data , should be supported by data provider, FINANCE1...FINANCE100
3.Extra Basic Data DYNAINFO(N) N:Number
Number Dynamic information, should be supported by data provider,DYNAINFO1..DYNAINFO100
3.Extra Basic Data VOLUNIT   Number Volume unit 100 or 1000, should be supported by data provider
3.Extra Basic Data CAPITAL   Number Capital of current stock, should be supported by data provider
3.Extra Basic Data DATACOUNT   Number Bars count of current data provider
4        
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
4.Date & Time DATEDIFF(f1,f2) f1:Data Array
f2:Data Array
Data Array Days between the two data arrays
4.Date & Time DATE   Data Array Get date array, the format is Year*10000+Month*100+Day
4.Date & Time OLEDATE   Data Array Get ole date array
4.Date & Time DOUBLEDATE   Data Array Get double date array
4.Date & Time LASTDOUBLEDATE   Number Return last double date
4.Date & Time DAY   Data Array Get day array.
4.Date & Time HOUR   Data Array Get hour array.
4.Date & Time MINUTE   Data Array Get minute array.
4.Date & Time MONTH   Data Array Get month array.
4.Date & Time TIME   Data Array Get time array,the format is Hour*10000+Minute*100+Second
4.Date & Time WEEK   Data Array Get week array,0..6, 0 means sunday,6 means saturday
4.Date & Time WEEKDAY   Data Array Get week array,0..6, 0 means sunday,6 means saturday
4.Date & Time YEAR   Data Array Get year array
5        
5.Reference functions MUL(f) f:Data Array
Data Array Multiple from the first bar
5.Reference functions SUM(f,N) f:Data Array
N:Number
Data Array Sum last N days value
5.Reference functions SUM(f) f:Data Array
Data Array Sum from the first bar
5.Reference functions COUNT(f,N) f:Data Array
N:Number
Data Array True count of last N days
5.Reference functions REF(f,N) f:Data Array
N:Number
Data Array Reference value of N days before
5.Reference functions EXTEND(f) f:Data Array
Data Array Extend last value to last bar
5.Reference functions MA(f,N) f:Data Array
N:Number
Data Array N days moving average
5.Reference functions EMA(f,N) f:Data Array
N:Number
Data Array N days exponential moving average
5.Reference functions SMA(f,N,M) f:Data Array
N:Number
M:Number
Data Array Simple moving average, equal to DMA(f,M/N), M<N
5.Reference functions 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
5.Reference functions HHV(f,N) f:Data Array
N:Number
Data Array N days highest value
5.Reference functions HHV(f) f:Data Array
Data Array Highest value
5.Reference functions LLV(f,N) f:Data Array
N:Number
Data Array N days lowest value
5.Reference functions LLV(f) f:Data Array
Data Array Lowest value
5.Reference functions HHVBARS(f,N) f:Data Array
N:Number
Data Array N days highest value bars count
5.Reference functions LLVBARS(f,N) f:Data Array
N:Number
Data Array N days lowest value bars count
5.Reference functions BARSCOUNT(f) f:Data Array
Data Array Bars count
5.Reference functions SUMBARS(f,N) f:Data Array
N:Number
Data Array Bars count when sum up to N
5.Reference functions BARSLAST(f) f:Data Array
Data Array Bars count when value > 0
5.Reference functions BARSSINCE(Cond) Cond:Data Array
Data Array Bars count since first Cond>0
5.Reference functions BACKSET(Cond,f,N) Cond:Data Array
f:Data Array
N:Number
Data Array Backset N bars to f when Cond>0
5.Reference functions BACKSET(Cond,N) Cond:Data Array
N:Number
Data Array Backset N bars to 1 when Cond>0
5.Reference functions FILTER(Cond,N) Cond:Data Array
N:Number
Data Array Set next N bars to 0 when Cond>0
5.Reference functions 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
5.Reference functions TOVALUE(Cond,f,Percent) Cond:Data Array
f:Data Array
Percent:Number
Data Array f by the Percent between every two COND.
6        
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
6.Logic functions 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
6.Logic functions NEAR(f1,f2,P) f1:Data Array
f2:Data Array
P:Number
Data Array f1 is near f2 in percent of P
6.Logic functions 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
6.Logic functions CROSS(f1,f2) f1:Data Array
f2:Data Array
Data Array If f1 cross f2 from below return 1, otherwise return 0
6.Logic functions 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
6.Logic functions NOT(f1) f1:Data Array
Data Array If f1==0 return 1 , otherwise return 0
6.Logic functions ISLASTVALUE(f) f:Data Array
Data Array Set last bar has values to 1 other bars to 0
6.Logic functions EXIST(f,N) f:Data Array
N:Number
Data Array If exist non-zero value in last N bars return 1 otherwise return 0
6.Logic functions EVERY(f,N) f:Data Array
N:Number
Data Array If exist zero value in last N bars return 0 otherwise return 1
6.Logic functions 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
6.Logic functions ISLASTBAR   Data Array Set last bar to 1 other bars to 0
6.Logic functions ISLASTDAY   Data Array return 1 if current bar belongs to last day
6.Logic functions ISUP   Data Array If close value > open value return 1 otherwise return 0
6.Logic functions ISDOWN   Data Array If close value < open value return 1 otherwise return 0
6.Logic functions ISEQUAL   Data Array If close value = open value return 1 otherwise return 0
7        
7.Basic Math functions MAX(fds) fds:
Data Array Maxinum values
7.Basic Math functions MIN(fds) fds:
Data Array Minimum values
7.Basic Math functions ABS(d) d:Number
Number Absolate value, will return double.
7.Basic Math functions ABS(f) f:Data Array
Data Array Absolute values
7.Basic Math functions FLOOR(f) f:Data Array
Data Array The smallest whole number greater than or equal to f
7.Basic Math functions CEILING(f) f:Data Array
Data Array The smallest whole number greater than or equal to f
7.Basic Math functions ROUND(f,decimals) f:Data Array
decimals:Number
Data Array Returns the number nearest the specified value
7.Basic Math functions ROUND(f) f:Data Array
Data Array Returns the number nearest the specified value
7.Basic Math functions INTPART(f) f:Data Array
Data Array The integer part of the value
7.Basic Math functions MOD(f1,f2) f1:Data Array
f2:Data Array
Data Array Equal to f1 % f2
7.Basic Math functions SGN(f) f:Data Array
Data Array The sign of value
7.Basic Math functions REVERSE(f) f:Data Array
Data Array Equal to -f
8        
8.Extra Math functions SIN(f) f:Data Array
Data Array Sin
8.Extra Math functions COS(f) f:Data Array
Data Array Cos
8.Extra Math functions TAN(f) f:Data Array
Data Array Tag
8.Extra Math functions ASIN(f) f:Data Array
Data Array Arc Sin
8.Extra Math functions ACOS(f) f:Data Array
Data Array Arc Cos
8.Extra Math functions ATAN(f) f:Data Array
Data Array Arc Tan
8.Extra Math functions LOG10(f) f:Data Array
Data Array 10 based Log
8.Extra Math functions LOG(f) f:Data Array
Data Array 10 based Log
8.Extra Math functions LOG(f,N) f:Data Array
N:Number
Data Array N based Log
8.Extra Math functions LN(f) f:Data Array
Data Array e based Log
8.Extra Math functions EXP(f) f:Data Array
Data Array e raised to the specified power
8.Extra Math functions SQRT(f) f:Data Array
Data Array Square root of the value
8.Extra Math functions SQRT(d) d:Number
Number Return square root of d
8.Extra Math functions SQR(f) f:Data Array
Data Array Square of the value
8.Extra Math functions POWER(f,N) f:Data Array
N:Number
Data Array N Power of the value
8.Extra Math functions POW(f,N) f:Data Array
N:Number
Data Array N Power of the value
9        
9.Statistics functions STD(f,N) f:Data Array
N:Number
Data Array N days standard value
9.Statistics functions STDP(f,N) f:Data Array
N:Number
Data Array N days StdP value
9.Statistics functions VAR(f,N) f:Data Array
N:Number
Data Array N days Variant value
9.Statistics functions VARP(f,N) f:Data Array
N:Number
Data Array N days VarP value
9.Statistics functions AVEDEV(f,N) f:Data Array
N:Number
Data Array N days average value
9.Statistics functions DEVSQ(f,N) f:Data Array
N:Number
Data Array N days DevSQ value
9.Statistics functions LR(f,N,Start) f:Data Array
N:Number
Start:Number
Data Array N days Linear Regression
9.Statistics functions MAXVALUE(f) f:Data Array
Number Maximum value of f
9.Statistics functions MINVALUE(f) f:Data Array
Number Minimum value of f
9.Statistics functions LR(f,N) f:Data Array
N:Number
Data Array N days Linear Regression
9.Statistics functions FORCAST(f,N) f:Data Array
N:Number
Data Array N days linear regression fore cast
9.Statistics functions SLOPE(f,N) f:Data Array
N:Number
Data Array N days linear regression slope
9.Statistics functions CORR(f1,f2,N) f1:Data Array
f2:Data Array
N:Number
Data Array N days correlation factor between f1 and f2
A        
A.Index functions ZIG(fMin,fMax,N) fMin:Data Array
fMax:Data Array
N:Number
Data Array N days Zig Zag
A.Index functions ZIG(f,N) f:Data Array
N:Number
Data Array N days Zig Zag
A.Index functions ZIG(N) N:Number
Data Array N days Zig Zag
A.Index functions ZIGP(fMin,fMax,N) fMin:Data Array
fMax:Data Array
N:Number
Data Array N days Zig Zag percent value
A.Index functions ZIGP(f,N) f:Data Array
N:Number
Data Array N days Zig Zag percent value
A.Index functions ZIGP(N) N:Number
Data Array N days Zig Zag percent value
A.Index functions 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
A.Index functions VALUEWHENBARS(Expr,N) Expr:Data Array
N:Number
Data Array Count Expr was true N times and reports the bars count
A.Index functions FINDPEAK(f) f:Data Array
Data Array Find Peak
A.Index functions FINDPEAK(fMin,fMax,N) fMin:Data Array
fMax:Data Array
N:Number
Data Array Find Peak based on Zig(N)
A.Index functions FINDPEAK(f,N) f:Data Array
N:Number
Data Array Find Peak based on Zig(N)
A.Index functions FINDPEAK(N) N:Number
Data Array Find Peak based on Zig(N)
A.Index functions FINDTROUGH(f) f:Data Array
Data Array Find Trough
A.Index functions FINDTROUGH(fMin,fMax,N) fMin:Data Array
fMax:Data Array
N:Number
Data Array Find Trough based on Zig(N)
A.Index functions FINDTROUGH(f,N) f:Data Array
N:Number
Data Array Find Trough based on Zig(N)
A.Index functions FINDTROUGH(N) N:Number
Data Array Find Trough based on Zig(N)
A.Index functions PEAK(fMin,fMax,N,M) fMin:Data Array
fMax:Data Array
N:Number
M:Number
Data Array Mth Peak line based on Zig(N)
A.Index functions PEAK(f,N,M) f:Data Array
N:Number
M:Number
Data Array Mth Peak line based on Zig(N)
A.Index functions PEAK(f,N) f:Data Array
N:Number
Data Array Peak line based on Zig(N)
A.Index functions PEAK(N,M) N:Number
M:Number
Data Array Peak line based on Zig(N)
A.Index functions PEAK(N) N:Number
Data Array Peak line based on Zig(N)
A.Index functions PEAKBARS(fMin,fMax,N,M) fMin:Data Array
fMax:Data Array
N:Number
M:Number
Data Array Mth Peak bars based on Zig(N)
A.Index functions PEAKBARS(f,N,M) f:Data Array
N:Number
M:Number
Data Array Mth Peak bars based on Zig(N)
A.Index functions PEAKBARS(f,N) f:Data Array
N:Number
Data Array Peak bars based on Zig(N)
A.Index functions PEAKBARS(N,M) N:Number
M:Number
Data Array Peak bars based on Zig(N)
A.Index functions PEAKBARS(N) N:Number
Data Array Peak bars based on Zig(N)
A.Index functions PEAKBARS(K,N,M) K:Number
N:Number
M:Number
Data Array Mth Peak bars based on Zig(N)
A.Index functions TROUGH(fMin,fMax,N,M) fMin:Data Array
fMax:Data Array
N:Number
M:Number
Data Array Mth trough line based on Zig(N)
A.Index functions TROUGH(f,N,M) f:Data Array
N:Number
M:Number
Data Array Mth trough line based on Zig(N)
A.Index functions TROUGH(f,N) f:Data Array
N:Number
Data Array Trough line based on Zig(N)
A.Index functions TROUGH(N,M) N:Number
M:Number
Data Array Mth trough line based on Zig(N)
A.Index functions TROUGH(N) N:Number
Data Array Trough line based on Zig(N)
A.Index functions TROUGH(K,N,M) K:Number
N:Number
M:Number
Data Array Mth trough line based on Zig(N)
A.Index functions TROUGHBARS(fMin,fMax,N,M) fMin:Data Array
fMax:Data Array
N:Number
M:Number
Data Array Mth trough bars based on Zig(N)
A.Index functions TROUGHBARS(f,N,M) f:Data Array
N:Number
M:Number
Data Array Mth trough bars based on Zig(N)
A.Index functions TROUGHBARS(N,M) N:Number
M:Number
Data Array Mth trough bars based on Zig(N)
A.Index functions TROUGHBARS(N) N:Number
Data Array Mth trough bars based on Zig(N)
A.Index functions TROUGHBARS(K,N,M) K:Number
N:Number
M:Number
Data Array Mth trough bars based on Zig(N)
A.Index functions SAR(N,STEP,MAXP) N:Number
STEP:Number
MAXP:Number
Data Array Sar,N is the first bar to calculate sar
A.Index functions SAR(STEP,MAXP) STEP:Number
MAXP:Number
Data Array Sar
A.Index functions SARTURN(N,STEP,MAXP) N:Number
STEP:Number
MAXP:Number
Data Array Sar turns, 0 ,1 or -1
B        
B.String functions STRCMP(s1,s2) s1:String
s2:String
Data Array Compare two strings
B.String functions STRNCMP(s1,s2,N) s1:String
s2:String
N:Number
Data Array Compare N chars of two strings
B.String functions INDEXOF(s1,s2) s1:String
s2:String
Data Array return the first occurrence of s2 in s1
B.String functions CONTAIN(s1,s2) s1:String
s2:String
Data Array return 1 if s1 contains s2, otherwise return 0.
B.String functions IF(Cond,s1,s2) Cond:Data Array
s1:String
s2:String
String return s1 if Cond is true, otherwise return s2.
B.String functions EXCHANGE   String Return current exchange, should be supported by data provider
B.String functions STKMARKET   String Return current exchange, should be supported by data provider
B.String functions CODE   String Return Stock Symbol
B.String functions STKLABEL   String Return Stock Symbol
B.String functions SYMBOL   String Return Stock Symbol
B.String functions STOCKNAME   String Return Stock Name
B.String functions STKNAME   String Return Stock Name
C        
C.Draw functions 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
C.Draw functions FILLRGN(Cond,Price,Price2) Cond:Data Array
Price:Data Array
Price2:Data Array
Data Array Fill region Price to Price2 when Cond is True
C.Draw functions FILLAREA(f1) f1:Data Array
Data Array Fill area below f1
C.Draw functions PARTLINE(Cond,f) Cond:Data Array
f:Data Array
Data Array Draw partial line
C.Draw functions VERTLINE(f) f:Data Array
Data Array Draw verticle line
C.Draw functions 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
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
C.Draw functions DRAWTEXT(Bar,f,Text,fds) Bar:Number
f:Data Array
Text:String
fds:
Data Array Draw Text on f on Bar
C.Draw functions 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
C.Draw functions DRAWICON(Cond,Price,ImageName) Cond:Data Array
Price:Data Array
ImageName:String
Data Array Draw Image on f when Cond is True
C.Draw functions POLYLINE(Cond,Price) Cond:Data Array
Price:Data Array
Data Array Poly line,The point was defined by f when Cond is True
C.Draw functions 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
C.Draw functions 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)
C.Draw functions 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
C.Draw functions STOCK   Data Array Draw stock bar based on O,C,H,L
D        
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')
D.Advanced functions FML(Symbol,FormulaName) Symbol:String
FormulaName:String
Data Array Reference other formula. For example : FML('MSFT','MACD[DIFF]')
D.Advanced functions FML(FormulaName) FormulaName:String
Data Array Reference other formula. For example : FML('MACD[DIFF]')
D.Advanced functions DATE2BAR(Date) Date:String
Number Convert string date to bar index,Date format is yyyy-MM-dd
E        
E.Indicator functions ATR(N) N:Number
Data Array N days average true range