资源加载中... loading...

TA

TA.MACD


```TA.MACD()```函数的返回值为二维数组,结构为:```[DIF, DEA, MACD]```。
array

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

```inReal```参数用于指定K线数据。
inReal
true
{@struct/Record Record}结构数组、数值数组
```optInFastPeriod```参数用于设置快周期。
optInFastPeriod
false
number
```optInSlowPeriod```参数用于设置慢周期。
optInSlowPeriod
false
number
```optInSignalPeriod```参数用于设置信号周期。
optInSignalPeriod
false
number

```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])
}
def main():
    r = exchange.GetRecords(PERIOD_M15)
    macd = TA.MACD(r, 12, 26, 9)
    Log("DIF:", macd[0], "DEA:", macd[1], "MACD:", macd[2])
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]);
}

发明者量化的TA指标库,优化了常用指标算法。 支持JavaScriptPythonC++语言策略的调用,开源TA库代码


{@fun/TA/TA.KDJ TA.KDJ}, {@fun/TA/TA.RSI TA.RSI}, {@fun/TA/TA.ATR TA.ATR}, {@fun/TA/TA.OBV TA.OBV},  {@fun/TA/TA.MA TA.MA}, {@fun/TA/TA.EMA TA.EMA}, {@fun/TA/TA.BOLL TA.BOLL}, {@fun/TA/TA.Alligator TA.Alligator}, {@fun/TA/TA.CMF TA.CMF}, {@fun/TA/TA.Highest TA.Highest}, {@fun/TA/TA.Lowest TA.Lowest}

### TA.KDJ

```TA.KDJ()```函数用于计算**随机指标**。

```TA.KDJ()```函数的返回值为二维数组,结构为:```[K, D, J]```。
array

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

```inReal```参数用于指定K线数据。
inReal
true
{@struct/Record Record}结构数组、数值数组
```period```参数用于设置周期1。
period
false
number
```kPeriod```参数用于设置周期2。
kPeriod
false
number
```dPeriod```参数用于设置周期3。
dPeriod
false
number

```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])
}
def main():
    r = exchange.GetRecords(PERIOD_M15)
    kdj = TA.KDJ(r, 9, 3, 3)
    Log("k:", kdj[0], "d:", kdj[1], "j:", kdj[2])
void main() {
    auto r = exchange.GetRecords();
    auto kdj = TA.KDJ(r, 9, 3, 3);
    Log("k:", kdj[0], "d:", kdj[1], "j:", kdj[2]);
}

{@fun/TA/TA.MACD TA.MACD}, {@fun/TA/TA.RSI TA.RSI}, {@fun/TA/TA.ATR TA.ATR}, {@fun/TA/TA.OBV TA.OBV},  {@fun/TA/TA.MA TA.MA}, {@fun/TA/TA.EMA TA.EMA}, {@fun/TA/TA.BOLL TA.BOLL}, {@fun/TA/TA.Alligator TA.Alligator}, {@fun/TA/TA.CMF TA.CMF}, {@fun/TA/TA.Highest TA.Highest}, {@fun/TA/TA.Lowest TA.Lowest}

### TA.RSI

```TA.RSI()```函数用于计算**强弱指标**。

```TA.RSI()```函数的返回值为:一维数组。
array

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

```inReal```参数用于指定K线数据。
inReal
true
{@struct/Record Record}结构数组、数值数组
```optInTimePeriod```参数用于设置周期。
optInTimePeriod
false
number

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

{@fun/TA/TA.MACD TA.MACD}, {@fun/TA/TA.KDJ TA.KDJ}, {@fun/TA/TA.ATR TA.ATR}, {@fun/TA/TA.OBV TA.OBV},  {@fun/TA/TA.MA TA.MA}, {@fun/TA/TA.EMA TA.EMA}, {@fun/TA/TA.BOLL TA.BOLL}, {@fun/TA/TA.Alligator TA.Alligator}, {@fun/TA/TA.CMF TA.CMF}, {@fun/TA/TA.Highest TA.Highest}, {@fun/TA/TA.Lowest TA.Lowest}

### TA.ATR

```TA.ATR()```函数用于计算**平均真实波幅指标**。

```TA.ATR()```函数的返回值为:一维数组。
array

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

```inPriceHLC```参数用于指定K线数据。
inPriceHLC
true
{@struct/Record Record}结构数组
```optInTimePeriod```参数用于设置周期。
optInTimePeriod
false
number

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

{@fun/TA/TA.MACD TA.MACD}, {@fun/TA/TA.KDJ TA.KDJ}, {@fun/TA/TA.RSI TA.RSI}, {@fun/TA/TA.OBV TA.OBV},  {@fun/TA/TA.MA TA.MA}, {@fun/TA/TA.EMA TA.EMA}, {@fun/TA/TA.BOLL TA.BOLL}, {@fun/TA/TA.Alligator TA.Alligator}, {@fun/TA/TA.CMF TA.CMF}, {@fun/TA/TA.Highest TA.Highest}, {@fun/TA/TA.Lowest TA.Lowest}

### TA.OBV

```TA.OBV()```函数用于计算**能量潮指标**。

```TA.OBV()```函数的返回值为:一维数组。
array

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

```inReal```参数用于指定K线数据。
inReal
true
{@struct/Record Record}结构数组、数值数组
```inPriceV```参数用于指定成交量数据。
inPriceV
false
{@struct/Record Record}结构数组

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

{@fun/TA/TA.MACD TA.MACD}, {@fun/TA/TA.KDJ TA.KDJ}, {@fun/TA/TA.RSI TA.RSI}, {@fun/TA/TA.ATR TA.ATR}, {@fun/TA/TA.MA TA.MA}, {@fun/TA/TA.EMA TA.EMA}, {@fun/TA/TA.BOLL TA.BOLL}, {@fun/TA/TA.Alligator TA.Alligator}, {@fun/TA/TA.CMF TA.CMF}, {@fun/TA/TA.Highest TA.Highest}, {@fun/TA/TA.Lowest TA.Lowest}

TA.MA


```TA.MA()```函数的返回值为:一维数组。
array

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

```inReal```参数用于指定K线数据。
inReal
true
{@struct/Record Record}结构数组、数值数组
```optInTimePeriod```参数用于设置周期。
optInTimePeriod
false
number

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

{@fun/TA/TA.MACD TA.MACD}, {@fun/TA/TA.KDJ TA.KDJ}, {@fun/TA/TA.RSI TA.RSI}, {@fun/TA/TA.ATR TA.ATR}, {@fun/TA/TA.OBV TA.OBV},  {@fun/TA/TA.EMA TA.EMA}, {@fun/TA/TA.BOLL TA.BOLL}, {@fun/TA/TA.Alligator TA.Alligator}, {@fun/TA/TA.CMF TA.CMF}, {@fun/TA/TA.Highest TA.Highest}, {@fun/TA/TA.Lowest TA.Lowest}

### TA.EMA

```TA.EMA()```函数用于计算**指数平均数指标**。

```TA.EMA()```函数的返回值为:一维数组。
array

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

```inReal```参数用于指定K线数据。
inReal
true
{@struct/Record Record}结构数组、数值数组
```optInTimePeriod```参数用于设置周期。
optInTimePeriod
false
number

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

{@fun/TA/TA.MACD TA.MACD}, {@fun/TA/TA.KDJ TA.KDJ}, {@fun/TA/TA.RSI TA.RSI}, {@fun/TA/TA.ATR TA.ATR}, {@fun/TA/TA.OBV TA.OBV},  {@fun/TA/TA.MA TA.MA}, {@fun/TA/TA.BOLL TA.BOLL}, {@fun/TA/TA.Alligator TA.Alligator}, {@fun/TA/TA.CMF TA.CMF}, {@fun/TA/TA.Highest TA.Highest}, {@fun/TA/TA.Lowest TA.Lowest}

### TA.BOLL

```TA.BOLL()```函数用于计算**布林带指标**。

```TA.BOLL()```函数的返回值为二维数组,结构为:```[upLine, midLine, downLine]```。
array

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

```inReal```参数用于指定K线数据。
inReal
true
{@struct/Record Record}结构数组、数值数组
```period```参数用于设置周期。
period
false
number
```multiplier```参数用于设置乘数。
multiplier
false
number

```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)
    }
}
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)
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);
    }
}

{@fun/TA/TA.MACD TA.MACD}, {@fun/TA/TA.KDJ TA.KDJ}, {@fun/TA/TA.RSI TA.RSI}, {@fun/TA/TA.ATR TA.ATR}, {@fun/TA/TA.OBV TA.OBV},  {@fun/TA/TA.MA TA.MA}, {@fun/TA/TA.EMA TA.EMA}, {@fun/TA/TA.Alligator TA.Alligator}, {@fun/TA/TA.CMF TA.CMF}, {@fun/TA/TA.Highest TA.Highest}, {@fun/TA/TA.Lowest TA.Lowest}

### TA.Alligator

```TA.Alligator()```函数用于计算**鳄鱼线指标**。

```TA.Alligator()```函数的返回值为二维数组,结构为:```[jawLine, teethLine, lipsLine]```。
array

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

```inReal```参数用于指定K线数据。
inReal
true
{@struct/Record Record}结构数组、数值数组
```jawLength```参数用于设置下颚周期。
jawLength
false
number
```teethLength```参数用于设置牙齿周期。
teethLength
false
number
```lipsLength```参数用于设置上唇周期。
lipsLength
false
number

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

{@fun/TA/TA.MACD TA.MACD}, {@fun/TA/TA.KDJ TA.KDJ}, {@fun/TA/TA.RSI TA.RSI}, {@fun/TA/TA.ATR TA.ATR}, {@fun/TA/TA.OBV TA.OBV},  {@fun/TA/TA.MA TA.MA}, {@fun/TA/TA.EMA TA.EMA}, {@fun/TA/TA.BOLL TA.BOLL}, {@fun/TA/TA.CMF TA.CMF}, {@fun/TA/TA.Highest TA.Highest}, {@fun/TA/TA.Lowest TA.Lowest}

### TA.CMF

```TA.CMF()```函数用于计算**蔡金货币流量指标**。

```TA.CMF()```函数的返回值为:一维数组。
array

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

```inReal```参数用于指定K线数据。
inReal
true
{@struct/Record Record}结构数组、数值数组
```inPriceV```参数用于指定成交量数据。
inPriceV
false
{@struct/Record Record}结构数组

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

{@fun/TA/TA.MACD TA.MACD}, {@fun/TA/TA.KDJ TA.KDJ}, {@fun/TA/TA.RSI TA.RSI}, {@fun/TA/TA.ATR TA.ATR}, {@fun/TA/TA.OBV TA.OBV}, {@fun/TA/TA.MA TA.MA}, {@fun/TA/TA.EMA TA.EMA}, {@fun/TA/TA.BOLL TA.BOLL}, {@fun/TA/TA.Alligator TA.Alligator}, {@fun/TA/TA.Highest TA.Highest}, {@fun/TA/TA.Lowest TA.Lowest}

TA.Highest


```TA.Highest()```函数返回最近一定周期内的某个属性的最大值,不包含当前Bar。
number

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

```inReal```参数用于指定K线数据。
inReal
true
{@struct/Record Record}结构数组、数值数组
```period```参数用于设置周期。
period
false
number
```attr```参数用于设置属性,可选:```Open```、```Close```、```Low```、```High```、```Volume```、```OpenInterest```。
attr
false
string

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

例如调用TA.Highest(records, 30, "High")函数,如果周期参数period设置为0, 指计算inReal参数传入的K线数据的所有Bar;如果属性参数attr不指定,则视为inReal参数传入的K线数据为普通数组。

{@fun/TA/TA.MACD TA.MACD}, {@fun/TA/TA.KDJ TA.KDJ}, {@fun/TA/TA.RSI TA.RSI}, {@fun/TA/TA.ATR TA.ATR}, {@fun/TA/TA.OBV TA.OBV}, {@fun/TA/TA.MA TA.MA}, {@fun/TA/TA.EMA TA.EMA}, {@fun/TA/TA.BOLL TA.BOLL}, {@fun/TA/TA.Alligator TA.Alligator}, {@fun/TA/TA.CMF TA.CMF}, {@fun/TA/TA.Lowest TA.Lowest}

TA.Lowest


```TA.Lowest()```函数返回最近一定周期内的某个属性的最小值,不包含当前Bar。
number

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

```inReal```参数用于指定K线数据。
inReal
true
{@struct/Record Record}结构数组、数值数组
```period```参数用于设置周期。
period
false
number
```attr```参数用于设置属性,可选:```Open```、```Close```、```Low```、```High```、```Volume```、```OpenInterest```。
attr
false
string

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

例如调用TA.Lowest(records, 30, "Low")函数,如果周期参数period设置为0, 指计算inReal参数传入的K线数据的所有Bar;如果属性参数attr不指定,则视为inReal参数传入的K线数据为普通数组。

并且第一个参数传入的不是```auto r = exchange.GetRecords()```函数调用时获取的K线数据```r```。
需要调用```r```的方法,传入具体属性数据。例如传入```r.Close()```收盘价数据。
```Close```、```High```、```Low```、```Open```、```Volume```如同```r.Close()```调用方式。

```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]);
}            

// 注意:第一个参数传入的不是r,需要调用r.Close()
auto highest = TA.Highest(r.Close(), 8);   
Log(highest);                     

}



{@fun/TA/TA.MACD TA.MACD}, {@fun/TA/TA.KDJ TA.KDJ}, {@fun/TA/TA.RSI TA.RSI}, {@fun/TA/TA.ATR TA.ATR}, {@fun/TA/TA.OBV TA.OBV},  {@fun/TA/TA.MA TA.MA}, {@fun/TA/TA.EMA TA.EMA}, {@fun/TA/TA.BOLL TA.BOLL}, {@fun/TA/TA.Alligator TA.Alligator}, {@fun/TA/TA.CMF TA.CMF}, {@fun/TA/TA.Highest TA.Highest}

### TA.SMA

```TA.SMA()```函数用于计算**简单移动平均指标**。

```TA.SMA()```函数的返回值为:一维数组。
array

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

```inReal```参数用于指定K线数据。
inReal
true
{@struct/Record Record}结构数组、数值数组
```optInTimePeriod```参数用于设置周期。
optInTimePeriod
false
number

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

TA.SMA()函数的optInTimePeriod参数的默认值为:9

{@fun/TA/TA.MACD TA.MACD}, {@fun/TA/TA.KDJ TA.KDJ}, {@fun/TA/TA.RSI TA.RSI}, {@fun/TA/TA.ATR TA.ATR}, {@fun/TA/TA.OBV TA.OBV}, {@fun/TA/TA.MA TA.MA}, {@fun/TA/TA.EMA TA.EMA}, {@fun/TA/TA.BOLL TA.BOLL}, {@fun/TA/TA.Alligator TA.Alligator}, {@fun/TA/TA.CMF TA.CMF}, {@fun/TA/TA.Highest TA.Highest}, {@fun/TA/TA.Lowest TA.Lowest}

Web3 Talib