Перестал работать getCandlesByIndex
причем время свечек видно в datetime, а остальные параметры open, high, low, close, volume и doesExist - нулевые.
Написал код для тестирования, индикатор ставим на график с идентификатором SBER_Chart:
На выходе получаем, нулевые данные (кроме времени свечей)
и так у разных брокеров (реальный счет) на споте и на фьюче.
причем время свечек видно в datetime, а остальные параметры open, high, low, close, volume и doesExist - нулевые.
Написал код для тестирования, индикатор ставим на график с идентификатором SBER_Chart:
| Код |
|---|
Settings=
{
Name = '#test'
}
function writeToFile(filename, content)
local file_handle = io.open(filename, 'w')
if file_handle then
file_handle:write(content)
file_handle:close()
return true
else
return false
end
end
function Init()
return 1
end
function OnCalculate(index)
id_chart = 'SBER_Chart'
local need_right_candles_count = 10
local line_number = 0
local candles_count = getNumCandles(id_chart)
local candles_from = candles_count - need_right_candles_count
check1 = tostring(id_chart)..'\n'..tostring(line_number)..'\n'..tostring(candles_from)..'\n'..tostring(need_right_candles_count)..'\n'..tostring(candles_count)..'\n'
local result_table, result_candles_count, result_chart_name = getCandlesByIndex(id_chart, line_number, candles_from, need_right_candles_count)
if result_table == nil or #result_table == 0 then
return "Empty result_table"
end
local fieldNames = {}
for field, _ in pairs(result_table[1]) do
table.insert(fieldNames, field)
end
check1 = check1..'My_Time\t'..table.concat(fieldNames, '\t') .. '\n'
for i = #result_table, 1, -1 do
if result_table[i].datetime == nil or
result_table[i].datetime.day == nil or
result_table[i].datetime.month == nil or
result_table[i].datetime.year == nil or
result_table[i].datetime.hour == nil or
result_table[i].datetime.min == nil or
result_table[i].datetime.sec == nil then
return nil
end
local candle_datetime = string.format("%02d.%02d.%04d %02d:%02d:%02d",
result_table[i].datetime.day,
result_table[i].datetime.month,
result_table[i].datetime.year,
result_table[i].datetime.hour,
result_table[i].datetime.min,
result_table[i].datetime.sec)
local formattedFields = {
candle_datetime
}
for j, fieldName in ipairs(fieldNames) do
local fieldValue = result_table[i][fieldName]
table.insert(formattedFields, tostring(fieldValue))
end
check1 = check1 .. table.concat(formattedFields, '\t')..'\n'
end
local filename_w = getWorkingFolder()..'\\check1.txt'
if writeToFile(filename_w, check1) then
return
else
return "Failed to write to file"
end
end
|
На выходе получаем, нулевые данные (кроме времени свечей)
| Код |
|---|
SBER_Chart 0 5595 10 5605 My_Time open close volume datetime doesExist low high 08.12.2023 15:00:00 0.0 0.0 0.0 table: 000000002BD45650 0 0.0 0.0 08.12.2023 14:50:00 0.0 0.0 0.0 table: 000000002BD455D0 0 0.0 0.0 08.12.2023 14:40:00 0.0 0.0 0.0 table: 000000002BD45550 0 0.0 0.0 08.12.2023 14:30:00 0.0 0.0 0.0 table: 000000002BD454D0 0 0.0 0.0 08.12.2023 14:20:00 0.0 0.0 0.0 table: 000000002BD45450 0 0.0 0.0 08.12.2023 14:10:00 0.0 0.0 0.0 table: 000000002BD453D0 0 0.0 0.0 08.12.2023 14:00:00 0.0 0.0 0.0 table: 000000002BD45350 0 0.0 0.0 08.12.2023 13:50:00 0.0 0.0 0.0 table: 000000002BD452D0 0 0.0 0.0 08.12.2023 13:40:00 0.0 0.0 0.0 table: 000000002BD45250 0 0.0 0.0 |