EDP = "NO"
FIRMID = "не об\255зателе\237"
RISK_CHANGE = "NO"
RISK_CONST = 6
LICENSE_RISK = "NO"
VEDLOG = "Ведётс\255"
PAPER = "RTS"
ACCOUNT_DEPO = "99999"
CLIENTCODE = "11111"
MODULD = "10092021"
SALUT = "1000000000"
MODULPRO ="10092021"
RISK_LIC = 6
Trade = function(Type)
-- function num : 0_0 , upvalues : _ENV
local temp = nil
trans_id = trans_id + 1
local spred = 100
local Price = 0
local operation = ""
if Type == "BUY" then
for j = 0, 9 do
Price = (getParamEx(CLASS_CODE, SEC_CODE, "offer")).param_value
if Price == 0 then
do
temp = (getParamEx(CLASS_CODE, SEC_CODE, "bid")).param_value
end
end
end
spred = Price + spred
operation = "B"
else
for j = 0, 9 do
Price = (getParamEx(CLASS_CODE, SEC_CODE, "bid")).param_value
if Price == 0 then
do
temp = (getParamEx(CLASS_CODE, SEC_CODE, "offer")).param_value
end
end
end
spred = Price - (spred)
operation = "S"
end
local Transaction = {ACCOUNT = ACCOUNT_DEPO, TYPE = "L", TRANS_ID = tostring(trans_id), CLASSCODE = CLASS_CODE, SECCODE = SEC_CODE, ACTION = "NEW_ORDER", OPERATION = operation, PRICE = tostring(spred), QUANTITY = "1"}
for j = 0, 10 do
sendTransaction(Transaction)
while not stopped and trans_Status == nil do
sleep(10)
end
local Status = trans_Status
trans_Status = nil
if Status ~= 3 then
row = t:AddLine()
t:SetValue(row, "Дата", Data.date, i)
t:SetValue(row, "Врем\255", TimeF, i)
t:SetValue(row, "Событи\229", (string.format)("Зайт\232 \226 сделку не удалос\252 по цене %d! Статус %d: %s", Price, Status, trans_result_msg), i)
i = i + 1
f:write("\n", Data.date, " ", TimeF, " ", (string.format)("Зайт\232 \226 сделку не удалос\252 по цене %d! Статус %d: %s", Price, Status, trans_result_msg))
f:flush()
f:seek("end", 0)
;
(bot.sendMessage)(from_id, (string.format)("Zajti v sdelku ne udalos` po cene %d! Status %d", Price, Status))
if j == 9 then
return false
end
else
row = t:AddLine()
t:SetValue(row, "Дата", Data.date, i)
t:SetValue(row, "Врем\255", TimeF, i)
t:SetValue(row, "Событи\229", (string.format)("\194 сделку зашл\232 по цене: %d", Price), i)
i = i + 1
f:write("\n", Data.date, " ", TimeF, " ", (string.format)("\194 сделку зашл\232 по цене: %d", Price))
f:flush()
f:seek("end", 0)
;
(bot.sendMessage)(from_id, (string.format)("V sdelku zashli po cene: %d", Price))
sleep(10)
return true
end
end
CountVolat = function(period, interV)
-- function num : 0_0_0 , upvalues : _ENV
tCandle = CreateDataSource(codeclass, codebum, interV)
NumEndCandle = tCandle:Size()
Sum = 0
for j = 1, period do
Volat = tCandle:H(NumEndCandle - j) - tCandle:L(NumEndCandle - j)
Sum = Sum + Volat
end
avgVolat = Sum / period
target = avgVolat / 2
Hi = tCandle:H(NumEndCandle - 1)
Lo = tCandle:L(NumEndCandle - 1)
HiO = tCandle:H(NumEndCandle - 2)
LoO = tCandle:L(NumEndCandle - 2)
trd = "ничего"
if HiO < Hi and LoO < Lo then trd = "Лонг"
else
if Hi < HiO and Lo < LoO then trd = "Шорт"
else
if HiO < Hi and Lo < LoO then trd = "Внеш.свеч\224"
else
if Hi < HiO and LoO < Lo then
HiOO = tCandle:H(NumEndCandle - 3)
LoOO = tCandle:L(NumEndCandle - 3)
if HiOO < HiO and LoOO < LoO then trd = "Лонг(внут\240.свеч\224)"
else
if HiO < HiOO and LoO < LoOO then trd = "Шорт(внут\240.свеч\224)"
else trd = "ХЗ"
end
end
else trd = "ничего"
end
end
end
end
trend = trd
return avgVolat, target, Hi, Lo, trend
end
insertLabel = function(labelType, labelDate, labelTime, yValue)
label_params = {}
if labelType == 1 then
label_params.IMAGE_PATH = "C:\\pic_qlua\\купл\255.bmp"
else
if labelType == 2 then
label_params.IMAGE_PATH = "C:\\pic_qlua\\продаж\224.bmp"
end
end
label_params.TIME = labelTime
label_params.DATE = labelDate
label_params.YVALUE = yValue
label_params.ALIGNMENT = TOP
AddLabel(id_grafic, label_params)
end
end
|