-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathEMA.lua
47 lines (31 loc) · 767 Bytes
/
EMA.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
require "IndexLibrary"
-- BOLL 指标
-- @param list K线数组
-- @param getMethod 计算字段
-- @param param {5, 10, 20, 40}
function EMAIndex(aryList, getMethod, param)
local listMapIndex = {}
local titles = {}
for i = 1, #param, 1 do
local title = "EMA"..param[i]
local cycle = param[i]
local funcEMA = EMA(getMethod, cycle, aryList)
local aryMANIndex = {}
titles[i] = title
listMapIndex[title] = aryMANIndex
for j = 1, #aryList, 1 do
aryMANIndex[j] = funcEMA(j)
end
end
local aryEMAIndex = {}
for j = 1, #aryList, 1 do
local ma = {}
for i = 1, #titles, 1 do
local title = titles[i]
local aryMaNIndex = listMapIndex[title]
ma[title] = aryMaNIndex[j]
end
aryEMAIndex[j] = ma
end
return aryEMAIndex
end