The TA.MACD()
function is used to calculate the exponential smoothed dissimilarity and similarity MACD indicator.
The return value of the TA.MACD()
function is a two-dimensional array with the structure: [DIF, DEA, MACD]
.
array
TA.MACD(inReal) TA.MACD(inReal, optInFastPeriod, optInSlowPeriod, optInSignalPeriod)
The inReal
parameter is used to specify the K-line data.
inReal
true
{@struct/Record Record} structure arrays, numeric arrays
The optInFastPeriod
parameter is used to set the fast period.
optInFastPeriod
false
number
The optInSlowPeriod
parameter is used to set the slow period.
optInSlowPeriod
false
number
The optInSignalPeriod
parameter is used to set the signal period.
optInSignalPeriod
false
number
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)
// Watching the logs, you can see that three arrays are returned, corresponding to DIF, DEA and 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]);
}
The TA
indicator library of FMZ Quant, optimized for common indicator algorithms. It supports JavaScript
, Python
, C++
language strategy calls, 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
.
{@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}
The TA.KDJ()
function is used to calculate stochastic indicators.
The return value of the TA.KDJ()
function is a two-dimensional array with the structure: [K, D, J]
.
array
TA.KDJ(inReal) TA.KDJ(inReal, period, kPeriod, dPeriod)
The inReal
parameter is used to specify the K-line data.
inReal
true
{@struct/Record Record} structure arrays, numeric arrays
The period
parameter is used to set period 1.
period
false
number
The kPeriod
parameter is used to set period 2.
kPeriod
false
number
The dPeriod
parameter is used to set period 3.
dPeriod
false
number
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]);
}
The default values for the period
, kPeriod
, and dPeriod
parameters of the TA.KDJ()
function are: 9
, 3
, and 3
.
{@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}
The TA.RSI()
function is used to calculate the Strength Indicator.
The return value of the TA.RSI()
function is: a one-dimensional array.
array
TA.RSI(inReal) TA.RSI(inReal, optInTimePeriod)
The inReal
parameter is used to specify the K-line data.
inReal
true
{@struct/Record Record} structure arrays, numeric arrays
The optInTimePeriod
parameter is used to set the period.
optInTimePeriod
false
number
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);
}
The default value of the optInTimePeriod
parameter of the TA.RSI()
function is: 14
.
{@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}
The TA.ATR()
function is used to calculate the Average True Volatility Indicator.
The return value of the TA.ATR()
function is: a one-dimensional array.
array
TA.ATR(inPriceHLC) TA.ATR(inPriceHLC, optInTimePeriod)
The inPriceHLC
parameter is used to specify the K-line data.
inPriceHLC
true
{@struct/Record Record} structure array
The optInTimePeriod
parameter is used to set the period.
optInTimePeriod
false
number
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);
}
The default value of the optInTimePeriod
parameter of the TA.ATR()
function is: 14
.
{@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}
The TA.OBV()
function is used to calculate the energy tide indicator.
The return value of the TA.OBV()
function is: a one-dimensional array.
array
TA.OBV(inReal) TA.OBV(inReal, inPriceV)
The inReal
parameter is used to specify the K-line data.
inReal
true
{@struct/Record Record} structure arrays, numeric arrays
The inPriceV
parameter is used to specify the transaction amount data.
inPriceV
false
{@struct/Record Record} structure array
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}
The TA.MA()
function is used to calculate the MACD Indicator.
The return value of the TA.MA()
function is: a one-dimensional array.
array
TA.MA(inReal) TA.MA(inReal, optInTimePeriod)
The inReal
parameter is used to specify the K-line data.
inReal
true
{@struct/Record Record} structure arrays, numeric arrays
The optInTimePeriod
parameter is used to set the period.
optInTimePeriod
false
number
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);
}
The default value of the optInTimePeriod
parameter of the TA.MA()
function is: 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.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}
The TA.EMA()
function is used to calculate the exponential average indicator.
The return value of the TA.EMA()
function is: a one-dimensional array.
array
TA.EMA(inReal) TA.EMA(inReal, optInTimePeriod)
The inReal
parameter is used to specify the K-line data.
inReal
true
{@struct/Record Record} structure arrays, numeric arrays
The optInTimePeriod
parameter is used to set the period.
optInTimePeriod
false
number
function main(){
var records = exchange.GetRecords()
// Determine if the number of K-line bars meets the calculation period of the indicator
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);
}
}
The default value of the optInTimePeriod
parameter of the TA.EMA()
function is: 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.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}
The TA.BOLL()
function is used to calculate the Bollinger Band indicator.
The return value of the TA.BOLL()
function is a two-dimensional array with the structure: [upLine, midLine, downLine]
.
array
TA.BOLL(inReal) TA.BOLL(inReal, period, multiplier)
The inReal
parameter is used to specify the K-line data.
inReal
true
{@struct/Record Record} structure arrays, numeric arrays
The period
parameter is used to set the period.
period
false
number
The multiplier
parameter is used to set the multiplier.
multiplier
false
number
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);
}
}
The default values for the period
and multiplier
parameters of the TA.BOLL()
function are: 20
and 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.Alligator TA.Alligator}, {@fun/TA/TA.CMF TA.CMF}, {@fun/TA/TA.Highest TA.Highest}, {@fun/TA/TA.Lowest TA.Lowest}
The TA.Alligator()
function is used to calculate the Alligator Indicator.
The return value of the TA.Alligator()
function is a two-dimensional array with the structure: [jawLine, teethLine, lipsLine]
.
array
TA.Alligator(inReal) TA.Alligator(inReal, jawLength, teethLength, lipsLength)
The inReal
parameter is used to specify the K-line data.
inReal
true
{@struct/Record Record} structure arrays, numeric arrays
The jawLength
parameter is used to set the jaw period.
jawLength
false
number
The teethLength
parameter is used to set the teeth period.
teethLength
false
number
The lipsLength
parameter is used to set the upper lip period.
lipsLength
false
number
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]);
}
The default values of the jawLength
, teethLength
, and lipsLength
parameters of the TA.Alligator()
function are: 13
, 8
, and 5
.
{@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}
The TA.CMF()
function is used to calculate the Chaikin Money Flow Indicator.
The return value of the TA.CMF()
function is: a one-dimensional array.
array
TA.CMF(inReal) TA.CMF(inReal, inPriceV)
The inReal
parameter is used to specify the K-line data.
inReal
true
{@struct/Record Record} structure arrays, numeric arrays
The inPriceV
parameter is used to specify the volume data.
inPriceV
false
{@struct/Record Record} structure array
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}
The TA.Highest()
function is used to calculate the period highest price.
The TA.Highest()
function returns the maximum value of an attribute in the last certain period, excluding the current Bar.
number
TA.Highest(inReal) TA.Highest(inReal, period, attr)
The inReal
parameter is used to specify the K-line data.
inReal
true
{@struct/Record Record} structure arrays, numeric arrays
The period
parameter is used to set the period.
period
false
number
The attr
parameter is used to set the attributes, optionally: Open
, Close
, Low
, High
, Volume
, OpenInterest
.
attr
false
string
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);
}
For example, if the TA.Highest(records, 30, "High")
function is called, if the period parameter period
is set to 0
, it means to calculate all Bars
of the K-line data passed in by the inReal
parameter; if the attribute parameter attr
is not specified, the K-line data passed in by the inReal
parameter is considered to be an ordinary array.
{@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}
The TA.Lowest()
function is used to calculate the period lowest price.
The TA.Lowest()
function returns the minimum value of an attribute in the last certain period, excluding the current Bar.
number
TA.Lowest(inReal) TA.Lowest(inReal, period, attr)
The inReal
parameter is used to specify the K-line data.
inReal
true
{@struct/Record Record} structure arrays, numeric arrays
The period
parameter is used to set the period.
period
false
number
The attr
parameter is used to set the attributes, optionally: Open
, Close
, Low
, High
, Volume
, OpenInterest
.
attr
false
string
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);
}
For example, if the TA.Lowest(records, 30, "Low")
function is called, if the period parameter period
is set to 0
, it means to calculate all Bars
of the K-line data passed in by the inReal
parameter; if the attribute parameter attr
is not specified, the K-line data passed in by the inReal
parameter is considered to be an ordinary array.
The use of the TA.Highest()
and TA.Lowest()
functions in the C++
strategy needs to be noted that the Highest()
and Lowest()
functions each have only 2 parameters.
And the first parameter passed in is not the K-line data r
obtained when the function auto r = exchange.GetRecords()
was called.
You need to call the r
method and pass in the specific attribute data. For example, pass in the r.Close()
closing price data.
Close
, High
, Low
, Open
, Volume
as in the r.Close()
call method.
Example test of C++
language strategy:
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 is not r, you need to call 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}
The TA.SMA()
function is used to calculate the simple moving average indicator.
The return value of the TA.SMA()
function is: a one-dimensional array.
array
TA.SMA(inReal) TA.SMA(inReal, optInTimePeriod)
The inReal
parameter is used to specify the K-line data.
inReal
true
{@struct/Record Record} structure arrays, numeric arrays
The optInTimePeriod
parameter is used to set the period.
optInTimePeriod
false
number
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);
}
The default value of the optInTimePeriod
parameter of the TA.SMA()
function is: 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