The talib.MA()
function is used to calculate the Moving average.
The return value of the talib.MA()
function is: a one-dimensional array.
array
talib.MA(inReal) talib.MA(inReal, optInTimePeriod) talib.MA(inReal, optInTimePeriod, optInMAType)
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, the default value is 30.
optInTimePeriod
false
number
The optInMAType
parameter is used to set the mean type, the default value is 0.
optInMAType
false
number
function main() {
var records = exchange.GetRecords()
var ret = talib.MA(records)
Log(ret)
}
import talib
def main():
records = exchange.GetRecords()
ret = talib.MA(records.Close)
Log(ret)
void main() {
auto records = exchange.GetRecords();
auto ret = talib.MA(records);
Log(ret);
}
The MA()
function is described in the talib library documentation as: MA(Records[Close],Time Period = 30,MA Type = 0) = Array(outReal)