-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCreateDataSource_10candles.lua
More file actions
65 lines (40 loc) · 1.36 KB
/
CreateDataSource_10candles.lua
File metadata and controls
65 lines (40 loc) · 1.36 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function OnInit()
indexload = 0
end
function hhmmss(date_time)
local Hour = date_time.hour
if Hour<10 then Hour = "0"..Hour end
local Min = date_time.min
if Min<10 then Min = "0"..Min end
local Sec=date_time.sec
if Sec<10 then Sec="0"..Sec end
return Hour..Min..Sec
end
function DDMMYYYY(date_time)
local DD = date_time.day
if DD<10 then DD = "0"..DD end
local MM = date_time.month
if MM<10 then MM = "0"..MM end
local YYYY = date_time.year
return DD..MM..YYYY
end
function main()
ds, error_discr = CreateDataSource("TQBR", "ABRD", INTERVAL_M1)
repeat
sleep(100)
indexload = indexload + 1
until(ds:Size()~=0 or indexload>=10)
number_of_candles = ds:Size()
message("Количество свечей в источнике данных: "..number_of_candles)
for index = number_of_candles-9, number_of_candles do
openprice = ds:O(index)
highprice = ds:H(index)
lowprice = ds:L(index)
closeprice = ds:C(index)
volume = ds:V(index)
localtime = hhmmss(ds:T(index))
localdata = DDMMYYYY(ds:T(index))
message("Свеча "..index.." data:"..localdata.." time:"..localtime.." open="..openprice.." high="..highprice.." low="..lowprice.." close="..closeprice.." volume="..volume)
end
ds:Close() -- закрыть источник данных
end