-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathgetCandleByIndex_first_and_last_Candle.lua
More file actions
59 lines (35 loc) · 1.18 KB
/
getCandleByIndex_first_and_last_Candle.lua
File metadata and controls
59 lines (35 loc) · 1.18 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
function OnInit()
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()
tiker_id = "SBER_ID"
number_of_candles = getNumCandles(tiker_id)
mprice, a, b = getCandlesByIndex(tiker_id, 0, 0, number_of_candles)
for i = 0, number_of_candles, (number_of_candles - 1) do
openprice = mprice[i].open
highprice = mprice[i].high
lowprice = mprice[i].low
closeprice = mprice[i].close
volume = mprice[i].volume
localtime = hhmmss(mprice[i].datetime)
localdata = DDMMYYYY(mprice[i].datetime)
message(number_of_candles.." "..localdata.." "..localtime.." OPEN="..openprice.." HIGH="..highprice.." LOW="..lowprice.." CLOSE="..closeprice.." VOLUME="..volume)
end
message(a.." "..b)
end