Type/to search
Built-in Functions
Global
Version
Sleep
IsVirtual
Mail
Mail_Go
SetErrorFilter
GetPid
GetLastError
GetCommand
GetMeta
Dial
HttpQuery
HttpQuery_Go
Encode
UnixNano
Unix
GetOS
MD5
DBExec
UUID
EventLoop
__Serve
_G
_D
_N
_C
_Cross
JSON.parse
JSON.stringify
SetChannelData
GetChannelData
Log
Market
Trade
Account
Futures
NetSettings
Threads
threading
Thread
getThread
mainThread
currentThread
Lock
Condition
Event
Dict
pending
Thread
ThreadLock
ThreadEvent
ThreadCondition
ThreadDict
Web3
TA
Talib
talib.CDL2CROWS
talib.CDL3BLACKCROWS
talib.CDL3INSIDE
talib.CDL3LINESTRIKE
talib.CDL3OUTSIDE
talib.CDL3STARSINSOUTH
talib.CDL3WHITESOLDIERS
talib.CDLABANDONEDBABY
talib.CDLADVANCEBLOCK
talib.CDLBELTHOLD
talib.CDLBREAKAWAY
talib.CDLCLOSINGMARUBOZU
talib.CDLCONCEALBABYSWALL
talib.CDLCOUNTERATTACK
talib.CDLDARKCLOUDCOVER
talib.CDLDOJI
talib.CDLDOJISTAR
talib.CDLDRAGONFLYDOJI
talib.CDLENGULFING
talib.CDLEVENINGDOJISTAR
talib.CDLEVENINGSTAR
talib.CDLGAPSIDESIDEWHITE
talib.CDLGRAVESTONEDOJI
talib.CDLHAMMER
talib.CDLHANGINGMAN
talib.CDLHARAMI
talib.CDLHARAMICROSS
talib.CDLHIGHWAVE
talib.CDLHIKKAKE
talib.CDLHIKKAKEMOD
talib.CDLHOMINGPIGEON
talib.CDLIDENTICAL3CROWS
talib.CDLINNECK
talib.CDLINVERTEDHAMMER
talib.CDLKICKING
talib.CDLKICKINGBYLENGTH
talib.CDLLADDERBOTTOM
talib.CDLLONGLEGGEDDOJI
talib.CDLLONGLINE
talib.CDLMARUBOZU
talib.CDLMATCHINGLOW
talib.CDLMATHOLD
talib.CDLMORNINGDOJISTAR
talib.CDLMORNINGSTAR
talib.CDLONNECK
talib.CDLPIERCING
talib.CDLRICKSHAWMAN
talib.CDLRISEFALL3METHODS
talib.CDLSEPARATINGLINES
talib.CDLSHOOTINGSTAR
talib.CDLSHORTLINE
talib.CDLSPINNINGTOP
talib.CDLSTALLEDPATTERN
talib.CDLSTICKSANDWICH
talib.CDLTAKURI
talib.CDLTASUKIGAP
talib.CDLTHRUSTING
talib.CDLTRISTAR
talib.CDLUNIQUE3RIVER
talib.CDLUPSIDEGAP2CROWS
talib.CDLXSIDEGAP3METHODS
talib.AD
talib.ADOSC
talib.OBV
talib.ACOS
talib.ASIN
talib.ATAN
talib.CEIL
talib.COS
talib.COSH
talib.EXP
talib.FLOOR
talib.LN
talib.LOG10
talib.SIN
talib.SINH
talib.SQRT
talib.TAN
talib.TANH
talib.MAX
talib.MAXINDEX
talib.MIN
talib.MININDEX
talib.MINMAX
talib.MINMAXINDEX
talib.SUM
talib.HT_DCPERIOD
talib.HT_DCPHASE
talib.HT_PHASOR
talib.HT_SINE
talib.HT_TRENDMODE
talib.ATR
talib.NATR
talib.TRANGE
talib.BBANDS
talib.DEMA
talib.EMA
talib.HT_TRENDLINE
talib.KAMA
talib.MA
talib.MAMA
talib.MIDPOINT
talib.MIDPRICE
talib.SAR
talib.SAREXT
talib.SMA
talib.T3
talib.TEMA
talib.TRIMA
talib.WMA
talib.LINEARREG
talib.LINEARREG_ANGLE
talib.LINEARREG_INTERCEPT
talib.LINEARREG_SLOPE
talib.STDDEV
talib.TSF
talib.VAR
talib.ADX
talib.ADXR
talib.APO
talib.AROON
talib.AROONOSC
talib.BOP
talib.CCI
talib.CMO
talib.DX
talib.MACD
talib.MACDEXT
talib.MACDFIX
talib.MFI
talib.MINUS_DI
talib.MINUS_DM
talib.MOM
talib.PLUS_DI
talib.PLUS_DM
talib.PPO
talib.ROC
talib.ROCP
talib.ROCR
talib.ROCR100
talib.RSI
talib.STOCH
talib.STOCHF
talib.STOCHRSI
talib.TRIX
talib.ULTOSC
talib.WILLR
talib.AVGPRICE
talib.MEDPRICE
talib.TYPPRICE
talib.WCLPRICE
OS
Structures
Built-in Variables

The TA.MACD() function is used to calculate the Moving Average Convergence Divergence indicator.

TA.MACD(inReal)
TA.MACD(inReal, optInFastPeriod, optInSlowPeriod, optInSignalPeriod)

Examples

javascript
function main(){ // 可以填入不同k线周期,比如PERIOD_M1,PERIOD_M30,PERIOD_H1...... var records = exchange.GetRecords(PERIOD_M15) var macd = TA.MACD(records, 12, 26, 9) // 观看日志可得知返回三个数组,分别对应DIF,DEA,MACD Log("DIF:", macd[0], "DEA:", macd[1], "MACD:", macd[2]) }
python
def main(): r = exchange.GetRecords(PERIOD_M15) macd = TA.MACD(r, 12, 26, 9) Log("DIF:", macd[0], "DEA:", macd[1], "MACD:", macd[2])
c++
void main() { auto r = exchange.GetRecords(PERIOD_M15); auto macd = TA.MACD(r, 12, 26, 9); Log("DIF:", macd[0], "DEA:", macd[1], "MACD:", macd[2]); }

Returns

TypeDescription

array

The TA.MACD() function returns a two-dimensional array with the structure: [DIF, DEA, MACD].

Arguments

NameTypeRequiredDescription

inReal

Record structure array / numeric array

Yes

The inReal parameter is used to specify the K-line data.

optInFastPeriod

number

No

The optInFastPeriod parameter is used to set the fast period.

optInSlowPeriod

number

No

The optInSlowPeriod parameter is used to set the slow period.

optInSignalPeriod

number

No

The optInSignalPeriod parameter is used to set the signal line period.

See Also

Remarks

FMZ Quant's TA indicator library optimizes common technical indicator algorithms. It supports strategy calls in JavaScript, Python, and C++ languages, open source TA library code.

The default values for the optInFastPeriod, optInSlowPeriod, and optInSignalPeriod parameters of the TA.MACD() function are: 12, 26, and 9 respectively.

The TA.KDJ() function is used to calculate the Stochastic Oscillator.

TA.KDJ(inReal)
TA.KDJ(inReal, period, kPeriod, dPeriod)

Examples

javascript
function main(){ var records = exchange.GetRecords(PERIOD_M15) var kdj = TA.KDJ(records, 9, 3, 3) Log("k:", kdj[0], "d:", kdj[1], "j:", kdj[2]) }
python
def main(): r = exchange.GetRecords(PERIOD_M15) kdj = TA.KDJ(r, 9, 3, 3) Log("k:", kdj[0], "d:", kdj[1], "j:", kdj[2])
c++
void main() { auto r = exchange.GetRecords(); auto kdj = TA.KDJ(r, 9, 3, 3); Log("k:", kdj[0], "d:", kdj[1], "j:", kdj[2]); }

Returns

TypeDescription

array

The TA.KDJ() function returns a two-dimensional array with the structure: [K, D, J].

Arguments

NameTypeRequiredDescription

inReal

Record structure array / numeric array

Yes

The inReal parameter is used to specify the K-line data.

period

number

No

The period parameter is used to set the first period.

kPeriod

number

No

The kPeriod parameter is used to set the second period.

dPeriod

number

No

The dPeriod parameter is used to set the third period.

See Also

Remarks

The default values for the period, kPeriod, and dPeriod parameters of the TA.KDJ() function are: 9, 3, and 3 respectively.

The TA.RSI() function is used to calculate the Relative Strength Index.

TA.RSI(inReal)
TA.RSI(inReal, optInTimePeriod)

Examples

javascript
function main(){ var records = exchange.GetRecords(PERIOD_M30) var rsi = TA.RSI(records, 14) Log(rsi) }
python
def main(): r = exchange.GetRecords(PERIOD_M30) rsi = TA.RSI(r, 14) Log(rsi)
c++
void main() { auto r = exchange.GetRecords(PERIOD_M30); auto rsi = TA.RSI(r, 14); Log(rsi); }

Returns

TypeDescription

array

The return value of the TA.RSI() function is: a one-dimensional array.

Arguments

NameTypeRequiredDescription

inReal

Record structure array / numeric array

Yes

The inReal parameter is used to specify the K-line data.

optInTimePeriod

number

No

The optInTimePeriod parameter is used to set the calculation period.

See Also

Remarks

The default value of the optInTimePeriod parameter for the TA.RSI() function is: 14.

The TA.ATR() function is used to calculate the Average True Range indicator.

TA.ATR(inPriceHLC)
TA.ATR(inPriceHLC, optInTimePeriod)

Examples

javascript
function main(){ var records = exchange.GetRecords(PERIOD_M30) var atr = TA.ATR(records, 14) Log(atr) }
python
def main(): r = exchange.GetRecords(PERIOD_M30) atr = TA.ATR(r, 14) Log(atr)
c++
void main() { auto r = exchange.GetRecords(PERIOD_M30); auto atr = TA.ATR(r, 14); Log(atr); }

Returns

TypeDescription

array

The TA.ATR() function returns a one-dimensional array.

Arguments

NameTypeRequiredDescription

inPriceHLC

Record structure array

Yes

The inPriceHLC parameter is used to specify the K-line data.

optInTimePeriod

number

No

The optInTimePeriod parameter is used to set the calculation period.

See Also

Remarks

The default value of the optInTimePeriod parameter for the TA.ATR() function is: 14.

The TA.OBV() function is used to calculate the On-Balance Volume indicator.

TA.OBV(inReal)
TA.OBV(inReal, inPriceV)

Examples

javascript
function main(){ var records = exchange.GetRecords(PERIOD_M30) var obv = TA.OBV(records) Log(obv) }
python
def main(): r = exchange.GetRecords(PERIOD_M30) obv = TA.OBV(r) Log(obv)
c++
void main() { auto r = exchange.GetRecords(PERIOD_M30); auto obv = TA.OBV(r); Log(obv); }

Returns

TypeDescription

array

The TA.OBV() function returns a one-dimensional array containing the calculated On-Balance Volume indicator values.

Arguments

NameTypeRequiredDescription

inReal

Record structure array / numeric array

Yes

The inReal parameter is used to specify K-line data.

inPriceV

Record structure array

No

The inPriceV parameter is used to specify volume data.

See Also

The TA.MA() function is used to calculate the Moving Average indicator.

TA.MA(inReal)
TA.MA(inReal, optInTimePeriod)

Examples

javascript
function main(){ var records = exchange.GetRecords(PERIOD_M30) var ma = TA.MA(records, 14) Log(ma) }
python
def main(): r = exchange.GetRecords(PERIOD_M30) ma = TA.MA(r, 14) Log(ma)
c++
void main() { auto r = exchange.GetRecords(PERIOD_M30); auto ma = TA.MA(r, 14); Log(ma); }

Returns

TypeDescription

array

The TA.MA() function returns a one-dimensional array.

Arguments

NameTypeRequiredDescription

inReal

Record structure array / numeric array

Yes

The inReal parameter is used to specify the K-line data.

optInTimePeriod

number

No

The optInTimePeriod parameter is used to set the calculation period.

See Also

Remarks

The default value of the optInTimePeriod parameter for the TA.MA() function is: 9.

The TA.EMA() function is used to calculate the Exponential Moving Average indicator.

TA.EMA(inReal)
TA.EMA(inReal, optInTimePeriod)

Examples

javascript
function main(){ var records = exchange.GetRecords() // 判断K线bar数量是否满足指标计算周期 if (records && records.length > 9) { var ema = TA.EMA(records, 9) Log(ema) } }
python
def main(): r = exchange.GetRecords() if r and len(r) > 9: ema = TA.EMA(r, 9) Log(ema)
c++
void main() { auto r = exchange.GetRecords(); if(r.Valid && r.size() > 9) { auto ema = TA.EMA(r, 9); Log(ema); } }

Returns

TypeDescription

array

The return value of the TA.EMA() function is: a one-dimensional array.

Arguments

NameTypeRequiredDescription

inReal

Record structure array / numeric array

Yes

The inReal parameter is used to specify the K-line data.

optInTimePeriod

number

No

The optInTimePeriod parameter is used to set the calculation period.

See Also

Remarks

The default value of the optInTimePeriod parameter for the TA.EMA() function is: 9.

The TA.BOLL() function is used to calculate the Bollinger Bands indicator.

TA.BOLL(inReal)
TA.BOLL(inReal, period, multiplier)

Examples

javascript
function main() { var records = exchange.GetRecords() if(records && records.length > 20) { var boll = TA.BOLL(records, 20, 2) var upLine = boll[0] var midLine = boll[1] var downLine = boll[2] Log(upLine) Log(midLine) Log(downLine) } }
python
def main(): r = exchange.GetRecords() if r and len(r) > 20: boll = TA.BOLL(r, 20, 2) upLine = boll[0] midLine = boll[1] downLine = boll[2] Log(upLine) Log(midLine) Log(downLine)
c++
void main() { auto r = exchange.GetRecords(); if(r.Valid && r.size() > 20) { auto boll = TA.BOLL(r, 20, 2); auto upLine = boll[0]; auto midLine = boll[1]; auto downLine = boll[2]; Log(upLine); Log(midLine); Log(downLine); } }

Returns

TypeDescription

array

The TA.BOLL() function returns a two-dimensional array with the structure: [upLine, midLine, downLine].

Arguments

NameTypeRequiredDescription

inReal

Record structure array / numeric array

Yes

The inReal parameter is used to specify the K-line data.

period

number

No

The period parameter is used to set the calculation period.

multiplier

number

No

The multiplier parameter is used to set the standard deviation multiplier.

See Also

Remarks

The default values for the period and multiplier parameters of the TA.BOLL() function are: 20 and 2 respectively.

The TA.Alligator() function is used to calculate the Alligator Indicator.

TA.Alligator(inReal)
TA.Alligator(inReal, jawLength, teethLength, lipsLength)

Examples

javascript
function main(){ var records = exchange.GetRecords() var alligator = TA.Alligator(records) Log("jawLine:", alligator[0]) Log("teethLine:", alligator[1]) Log("lipsLine:", alligator[2]) }
python
def main(): records = exchange.GetRecords() alligator = TA.Alligator(records) Log("jawLine:", alligator[0]) Log("teethLine:", alligator[1]) Log("lipsLine:", alligator[2])
c++
void main() { auto records = exchange.GetRecords(); auto alligator = TA.Alligator(records); Log("jawLine:", alligator[0]); Log("teethLine:", alligator[1]); Log("lipsLine:", alligator[2]); }

Returns

TypeDescription

array

The TA.Alligator() function returns a two-dimensional array with the data structure: [jawLine, teethLine, lipsLine], corresponding to the Alligator's jaw line, teeth line, and lips line respectively.

Arguments

NameTypeRequiredDescription

inReal

Record structure array / numeric array

Yes

The inReal parameter is used to specify the K-line data.

jawLength

number

No

The jawLength parameter is used to set the period length of the Alligator's jaw line.

teethLength

number

No

The teethLength parameter is used to set the period length of the Alligator's teeth line.

lipsLength

number

No

The lipsLength parameter is used to set the period length of the Alligator's lips line.

See Also

Remarks

The default values for the jawLength, teethLength, and lipsLength parameters of the TA.Alligator() function are: 13, 8, and 5 respectively.

The TA.CMF() function is used to calculate the Chaikin Money Flow indicator.

TA.CMF(inReal)
TA.CMF(inReal, inPriceV)

Examples

javascript
function main() { var records = exchange.GetRecords() var cmf = TA.CMF(records) Log(cmf) }
python
def main(): records = exchange.GetRecords() cmf = TA.CMF(records) Log(cmf)
c++
void main() { auto records = exchange.GetRecords(); auto cmf = TA.CMF(records); Log(cmf); }

Returns

TypeDescription

array

The TA.CMF() function returns a one-dimensional array.

Arguments

NameTypeRequiredDescription

inReal

Record structure array / numeric array

Yes

The inReal parameter is used to specify K-line data.

inPriceV

Record structure array

No

The inPriceV parameter is used to specify volume data.

See Also

The TA.Highest() function is used to calculate the highest price within a specified period.

TA.Highest(inReal)
TA.Highest(inReal, period, attr)

Examples

javascript
function main() { var records = exchange.GetRecords() var highestForOpen = TA.Highest(records, 10, "Open") Log(highestForOpen) }
python
def main(): records = exchange.GetRecords() highestForOpen = TA.Highest(records, 10, "Open") Log(highestForOpen)
c++
void main() { auto records = exchange.GetRecords(); auto highestForOpen = TA.Highest(records.Open(), 10); Log(highestForOpen); }

Returns

TypeDescription

number

The TA.Highest() function returns the maximum value of a specified attribute within the specified period, excluding the current Bar.

Arguments

NameTypeRequiredDescription

inReal

Record structure array / numeric array

Yes

The inReal parameter is used to specify the K-line data source.

period

number

No

The period parameter is used to set the calculation period length.

attr

string

No

The attr parameter is used to set the K-line attribute to be calculated. Optional values: Open, Close, Low, High, Volume, OpenInterest.

See Also

Remarks

For example, when calling TA.Highest(records, 30, "High") function: If the period parameter period is set to 0, it calculates the highest value of all Bars in the K-line data passed by the inReal parameter; If the attribute parameter attr is not specified, the data passed by the inReal parameter is treated as a regular numeric array.

The TA.Lowest() function is used to calculate the period lowest price.

TA.Lowest(inReal)
TA.Lowest(inReal, period, attr)

Examples

javascript
function main() { var records = exchange.GetRecords() var lowestForOpen = TA.Lowest(records, 10, "Open") Log(lowestForOpen) }
python
def main(): records = exchange.GetRecords() lowestForOpen = TA.Lowest(records, 10, "Open") Log(lowestForOpen)
c++
void main() { auto records = exchange.GetRecords(); auto lowestForOpen = TA.Lowest(records.Open(), 10); Log(lowestForOpen); }

Returns

TypeDescription

number

The TA.Lowest() function returns the minimum value of a certain attribute within the specified period, excluding the current Bar.

Arguments

NameTypeRequiredDescription

inReal

Record structure array / numeric array

Yes

The inReal parameter is used to specify the K-line data.

period

number

No

The period parameter is used to set the calculation period.

attr

string

No

The attr parameter is used to set the K-line attribute, optional values: Open, Close, Low, High, Volume, OpenInterest.

See Also

Remarks

For example, when calling TA.Lowest(records, 30, "Low") function, if the period parameter period is set to 0, it calculates all Bars of the K-line data passed in the inReal parameter; if the attribute parameter attr is not specified, the K-line data passed in the inReal parameter is treated as a regular array.

When using TA.Highest() and TA.Lowest() functions in C++ strategies, note that Highest() and Lowest() functions each have only 2 parameters, and the first parameter is not the K-line data r obtained by calling auto r = exchange.GetRecords() function. You need to call the method of r and pass in specific attribute data. For example, pass in r.Close() closing price data. Close, High, Low, Open, Volume all use the calling method like r.Close().

C++ language strategy test example:

c++
void main() { Records r; r.Valid = true; for (auto i = 0; i < 10; i++) { Record ele; ele.Time = i * 100000; ele.High = i * 10000; ele.Low = i * 1000; ele.Close = i * 100; ele.Open = i * 10; ele.Volume = i * 1; r.push_back(ele); } for(int j = 0; j < r.size(); j++){ Log(r[j]); } // Note: The first parameter is not r, need to call r.Close() auto highest = TA.Highest(r.Close(), 8); Log(highest); }

The TA.SMA() function is used to calculate the Simple Moving Average indicator.

TA.SMA(inReal)
TA.SMA(inReal, optInTimePeriod)

Examples

javascript
function main(){ var records = exchange.GetRecords(PERIOD_M30) var sma = TA.SMA(records, 14) Log(sma) }
python
def main(): r = exchange.GetRecords(PERIOD_M30) sma = TA.SMA(r, 14) Log(sma)
c++
void main() { auto r = exchange.GetRecords(PERIOD_M30); auto sma = TA.SMA(r, 14); Log(sma); }

Returns

TypeDescription

array

The return value of the TA.SMA() function is: a one-dimensional array.

Arguments

NameTypeRequiredDescription

inReal

Record structure array / numeric array

Yes

The inReal parameter is used to specify the K-line data.

optInTimePeriod

number

No

The optInTimePeriod parameter is used to set the calculation period.

See Also

Remarks

The default value of the optInTimePeriod parameter for the TA.SMA() function is: 9.