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 (MACD) indicator.

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

Examples

javascript
function main(){ // You can fill in different K-line periods, such as PERIOD_M1, PERIOD_M30, PERIOD_H1...... var records = exchange.GetRecords(PERIOD_M15) var macd = TA.MACD(records, 12, 26, 9) // Checking the logs shows that three arrays are returned, corresponding to DIF, DEA, and MACD respectively 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])
rust
fn main() { // You can fill in different K-line periods, such as PERIOD_M1, PERIOD_M30, PERIOD_H1...... let records = exchange.GetRecords(None, PERIOD_M15, None).unwrap(); let macd = TA.MACD(&records, 12, 26, 9); // Checking the logs shows that three arrays are returned, corresponding to DIF, DEA, and MACD respectively 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 return value of the TA.MACD() function is 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 (candlestick) data.

optInFastPeriod

number

No

The optInFastPeriod parameter is used to set the fast line period.

optInSlowPeriod

number

No

The optInSlowPeriod parameter is used to set the slow line 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 the algorithms of commonly used indicators and supports calls from JavaScript, Python, and C++ strategies. For details, see the open-source TA library code.

The default values of 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 (KDJ).

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])
rust
fn main() { let records = exchange.GetRecords(None, PERIOD_M15, None).unwrap(); let kdj = TA.KDJ(&records, 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 return value of the TA.KDJ() function is 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 pass in K-line (candlestick) data.

period

number

No

The period parameter is used to set calculation period 1.

kPeriod

number

No

The kPeriod parameter is used to set calculation period 2.

dPeriod

number

No

The dPeriod parameter is used to set calculation period 3.

See Also

Remarks

The default values of 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 (RSI).

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)
rust
fn main() { let records = exchange.GetRecords(None, PERIOD_M30, None).unwrap(); let rsi = TA.RSI(&records, 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 struct array / numeric array

Yes

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

optInTimePeriod

number

No

The optInTimePeriod parameter is used to set the calculation period.

See Also

Remarks

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

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

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)
rust
fn main() { let records = exchange.GetRecords(None, PERIOD_M30, None).unwrap(); let atr = TA.ATR(&records, 14); Log!(atr); }
c++
void main() { auto r = exchange.GetRecords(PERIOD_M30); auto atr = TA.ATR(r, 14); Log(atr); }

Returns

TypeDescription

array

The return value of the TA.ATR() function is 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 of the TA.ATR() function is: 14.

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

TA.OBV(inReal)

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)
rust
fn main() { let records = exchange.GetRecords(None, PERIOD_M30, None).unwrap(); let obv = TA.OBV(&records); Log!(obv); }
c++
void main() { auto r = exchange.GetRecords(PERIOD_M30); auto obv = TA.OBV(r); Log(obv); }

Returns

TypeDescription

array

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

Arguments

NameTypeRequiredDescription

inReal

Record structure array

Yes

The inReal parameter is used to specify the K-line data (the closing price and volume in the K-line data are used in the calculation).

See Also

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

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)
rust
fn main() { let records = exchange.GetRecords(None, PERIOD_M30, None).unwrap(); let ma = TA.MA(&records, 14); Log!(ma); }
c++
void main() { auto r = exchange.GetRecords(PERIOD_M30); auto ma = TA.MA(r, 14); Log(ma); }

Returns

TypeDescription

array

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

Arguments

NameTypeRequiredDescription

inReal

Record struct 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 of the TA.MA() function is: 9.

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

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

Examples

javascript
function main(){ var records = exchange.GetRecords() // Check whether the number of K-line Bars meets the period required for indicator calculation 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)
rust
fn main() { let records = exchange.GetRecords(None, None, None).unwrap(); // Check whether the number of K-line Bars meets the period required for indicator calculation if records.len() > 9 { let ema = TA.EMA(&records, 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 pass in the K-line (candlestick) data.

optInTimePeriod

number

No

The optInTimePeriod parameter is used to set the calculation period.

See Also

Remarks

The default value of the optInTimePeriod parameter of 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)
rust
fn main() { let records = exchange.GetRecords(None, None, None).unwrap(); if records.len() > 20 { let boll = TA.BOLL(&records, 20, 2.0); let [upLine, midLine, downLine] = boll; 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 return value of the TA.BOLL() function is a two-dimensional array, with the structure [upLine, midLine, downLine].

Arguments

NameTypeRequiredDescription

inReal

Record struct array / numeric array

Yes

The inReal parameter is used to specify the K-line (candlestick) 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 multiplier (standard deviation multiplier).

See Also

Remarks

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

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])
rust
fn main() { let records = exchange.GetRecords(None, None, None).unwrap(); let alligator = TA.Alligator(&records, None, None, None); 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 return value of the TA.Alligator() function is a two-dimensional array with the structure: [jawLine, teethLine, lipsLine].

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 of the Jaw line.

teethLength

number

No

The teethLength parameter is used to set the period of the Teeth line.

lipsLength

number

No

The lipsLength parameter is used to set the period of the Lips line.

See Also

Remarks

The default values of 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 (CMF) indicator.

TA.CMF(inReal)
TA.CMF(inReal, periods)

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)
rust
fn main() { let records = exchange.GetRecords(None, None, None).unwrap(); let cmf = TA.CMF(&records, None); Log!(cmf); }
c++
void main() { auto records = exchange.GetRecords(); auto cmf = TA.CMF(records); Log(cmf); }

Returns

TypeDescription

array

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

Arguments

NameTypeRequiredDescription

inReal

Record structure array

Yes

The inReal parameter is used to specify the K-line (candlestick) data (the high, low, close prices, and volume in the K-line data are used in the calculation).

periods

number

No

The periods parameter is used to specify the calculation period, with a default value of 20.

See Also

The TA.Highest() function is used to calculate the highest price within a 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)
rust
fn main() { let records = exchange.GetRecords(None, None, None).unwrap(); // Rust's TA.Highest has no attribute name parameter; first extract the opening price numeric sequence, then calculate (not including the current Bar) let opens: Vec<f64> = records.iter().map(|r| r.Open).collect(); let highestForOpen = TA.Highest(&opens, 10); 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 certain attribute over the most recent specified period, not including the current Bar.

Arguments

NameTypeRequiredDescription

inReal

Record structure array / numeric array

Yes

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

period

number

No

The period parameter is used to set the calculation period.

attr

string

No

The attr parameter is used to specify the attribute. Optional values: Open, Close, Low, High, Volume, OpenInterest.

See Also

Remarks

For example, when calling the TA.Highest(records, 30, "High") function, if the period parameter period is set to 0, it means calculating all Bar in the K-line data passed in by the inReal parameter; if the attribute parameter attr is not specified, the data passed in by the inReal parameter is treated as an ordinary array.

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

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)
rust
fn main() { let records = exchange.GetRecords(None, None, None).unwrap(); // Rust's TA.Lowest has no attribute-name parameter; first extract the opening price numeric sequence, then calculate (not including the current Bar) let opens: Vec<f64> = records.iter().map(|r| r.Open).collect(); let lowestForOpen = TA.Lowest(&opens, 10); 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 over the most recent given period, not including the current Bar.

Arguments

NameTypeRequiredDescription

inReal

Record structure array / numeric array

Yes

The inReal parameter is used to specify the K-line (candlestick) 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 attribute. Optional values: Open, Close, Low, High, Volume, OpenInterest.

See Also

Remarks

For example, when calling the TA.Lowest(records, 30, "Low") function: if the period parameter period is set to 0, it means calculating over all Bar of the K-line data passed in via the inReal parameter; if the attribute parameter attr is not specified, the K-line data passed in via the inReal parameter is treated as an ordinary array.

When using the TA.Highest() and TA.Lowest() functions in a C++ strategy, note the following: the Highest() and Lowest() functions each have only 2 parameters, and the first parameter passed in is not the K-line data r obtained from calling auto r = exchange.GetRecords(), but rather requires calling a method of r to pass in specific attribute data. For example, pass in r.Close() for closing price data. The calling method for Close, High, Low, Open, Volume is the same as r.Close().

Test example for a C++ language strategy:

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 passed in is not r; you 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 (SMA) 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)
rust
fn main() { let records = exchange.GetRecords(None, PERIOD_M30, None).unwrap(); let sma = TA.SMA(&records, 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 pass in the K-line (candlestick) data.

optInTimePeriod

number

No

The optInTimePeriod parameter is used to set the calculation period.

See Also

Remarks

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