Код
PORTFOLIO_EX SampleCandleExport;
DESCRIPTION Пример экспорта графиков со свечками по DDE;
CLIENTS_LIST ALL_CLIENTS;
FIRMS_LIST ALL_FIRMS;
PROGRAM
secClass = "QJSIM"
secCode = "LKOH"
timeFrame = 5
candleMaxCount = 50
DELETE_ALL_ITEMS()
dateTime = GET_DATETIME()
yearPart = GET_VALUE(dateTime, "YEAR")
monthPart = GET_VALUE(dateTime, "MONTH")
dayPart = GET_VALUE(dateTime, "DAY")
hourPart = GET_VALUE(dateTime, "Hour")
minutePart = GET_VALUE(dateTime, "Min")
minutePart = timeFrame * FLOOR(minutePart / timeFrame)
for i from 1 to candleMaxCount
dateString = GetDataString(yearPart, monthPart, dayPart)
timeString = GetTimeString(hourPart, minutePart)
candle = GET_CANDLE(secClass, secCode, "", timeFrame, "PRICE", dateString, timeString)
open = GET_VALUE (candle, "Open") + 0
if (open>0)
high=GET_VALUE (Candle, "High")
low=GET_VALUE (Candle, "Low")
close=GET_VALUE (Candle, "Close")
volume = GET_VALUE(candle, "Volume")
output = CREATE_MAP()
output = SET_VALUE(output, "Date", dateString)
output = SET_VALUE(output, "Time", timeString)
output = SET_VALUE(output, "OpenPrice", open)
output = SET_VALUE(output, "HighPrice", high)
output = SET_VALUE(output, "LowPrice", low)
output = SET_VALUE(output, "ClosePrice", close)
output = SET_VALUE(output, "Volume", volume)
ADD_ITEM(i, output)
end if
minutePart = minutePart - timeFrame
if minutePart < 0
minutePart = 60 - timeFrame
hourPart = hourPart - 1
if hourPart < 0
hourPart = 23
dayPart = dayPart - 1
if dayPart < 1
dayPart = 31
monthPart = monthPart - 1
if monthPart < 1
monthPart = 12
yearPart = yearPart - 1
end if
end if
end if
end if
end for
func GetDataString(year, month, day)
if (LEN(month) < 2)
month = "0" & month
end if
if (LEN(day) < 2)
day = "0" & day
end if
result = year & month & day
end func
func GetTimeString(hour, min, sec)
if (LEN(hour) < 2)
hour = "0" & hour
end if
if (LEN(min) < 2)
Min = "0" & min
end if
result = Hour & min & "00"
end func
END_PROGRAM
PARAMETER Date;
PARAMETER_TITLE Дата;
PARAMETER_DESCRIPTION Дата cвечки;
PARAMETER_TYPE STRING(30);
END
PARAMETER Time;
PARAMETER_TITLE Время;
PARAMETER_DESCRIPTION Время cвечки;
PARAMETER_TYPE STRING(30);
END
PARAMETER OpenPrice;
PARAMETER_TITLE Цена открытия;
PARAMETER_DESCRIPTION Цена открытия свечки;
PARAMETER_TYPE NUMERIC(10,2);
END
PARAMETER HighPrice;
PARAMETER_TITLE Максимальная цена;
PARAMETER_DESCRIPTION Максимальная цена свечки;
PARAMETER_TYPE NUMERIC(10,2);
END
PARAMETER LowPrice;
PARAMETER_TITLE Минимальная цена;
PARAMETER_DESCRIPTION Минимальная цена свечки;
PARAMETER_TYPE NUMERIC(10,2);
END
PARAMETER ClosePrice;
PARAMETER_TITLE Цена закрытия;
PARAMETER_DESCRIPTION Цена закрытия свечки;
PARAMETER_TYPE NUMERIC(10,2);
END
PARAMETER Volume;
PARAMETER_TITLE Объем;
PARAMETER_DESCRIPTION Объем сделок в свечке;
PARAMETER_TYPE NUMERIC(10,0);
END
END_PORTFOLIO_EX