-
Notifications
You must be signed in to change notification settings - Fork 64
/
vwap.lua
50 lines (42 loc) · 1.05 KB
/
vwap.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
48
49
50
Settings=
{
Name = "*VWAP",
line =
{
{
Name = "VWAP",
Color = RGB(0, 0, 255),
Type = TYPE_LINE, --TYPE_DASHDOT,
Width = 2
},
{
Name = "pVWAP",
Color = RGB(255, 128, 0),
Type = TYPE_LINE, --TYPE_DASHDOT,
Width = 2
}
}
}
function Init()
return #Settings.line
end
DSInfo = nil
function OnCalculate(index)
local vwap = nil
local prevVwap = nil
if index == 1 then
DSInfo = getDataSourceInfo()
end
if index == Size() then
SetValue(index-41, 1, nil)
SetValue(index-1, 1, nil)
SetValue(index-41, 2, nil)
SetValue(index-1, 2, nil)
vwap = tonumber(getParamEx(DSInfo.class_code, DSInfo.sec_code,"WAPRICE").param_value)
prevVwap = tonumber(getParamEx(DSInfo.class_code, DSInfo.sec_code,"PREVWAPRICE").param_value)
if vwap == 0 then vwap = nil end
SetValue(index-40, 1,vwap)
SetValue(index-40, 2,prevVwap)
end
return vwap, prevVwap
end