Артем (Все сообщения пользователя)

Выбрать дату в календареВыбрать дату в календаре

Страницы: 1
Все индикаторы на Lua
 
Цитата
Цитата
Смнаписал:
Цитата
написал:
Добрый день!
Подскажите где взять indicators.zip под lua 5.4. У меня часть индикаторов на 5.4. и вместе на одном графике они не уживаются с 5.3.
indicators.zip  Это какой-то архив?
Вы где его взяли?
Вы думаете, что все должны знать, что у Вас в этом архиве?
Смотрите пост 80.Там есть ссылка, но там только lua 5.3, который не работает вместе с 5.4. Один индикатор psar я починил заменой  unpack(arg) на  table.unpack(arg), но не все можно так просто починить, нужно к автору этих индикаторов обращаться. И было бы здорово переделать их под 5.4, а не чтобы каждый сам их прилаживал под себя. Хотя и так тоже наверное можно. Вот переделанный мной Psar под lua 5.4
Код
Settings = {
Name = "*PSAR (Parabolic SAR)", 
Step = 0.02,
MaxStep = 0.2, 
line = {{
      Name = "Horizontal line",
      Type = TYPE_LINE, 
      Color = RGB(140, 140, 140)
      },
      {
      Width = 3,
      Name = "PSAR_Up", 
      Type = TYPE_POINT, 
      Color = RGB(221, 44, 44)
      },
      {
      Width = 3,
      Name = "PSAR_Down", 
      Type = TYPE_POINT, 
      Color = RGB(0, 206, 0)
      }
      },
Round = "off",
Multiply = 1,
Horizontal_line="off"
}

function Init()
   func = PSAR()
   return #Settings.line
end

function OnCalculate(Index) 
local Out = ConvertValue(Settings, func(Index, Settings))
local HL = tonumber(Settings.Horizontal_line)
   if Out then
      if Out > ((H(Index)-L(Index))/2)+L(Index) then
         return HL,Out,nil
      else
         return HL,nil,Out
      end
   else
      return HL,nil,nil
   end
end

function PSAR() --Parabolic SAR ("PSAR")
   local tmp = {pp=nil, p=nil}
   local it = {ppp=0, pp=0, p=0, l=0}
return function (I, Fsettings, ds)
local Out = nil
local Fsettings=(Fsettings or {})
local Step = (Fsettings.Step or 0.02)
local MaxStep = (Fsettings.MaxStep or 0.2)
   if I == 1 then
      tmp = {pp=nil, p=nil}
      it = {ppp=0, pp=0, p=0, l=0}
   end
   if CandleExist(I,ds) then
      if I~=it.p then 
         it={ppp=it.pp, pp=it.p, p=I, l=it.l+1}
         tmp.pp = tmp.p
      end
      local cand = {ppp=nil, pp=nil, p=nil}
      tmp.p = {Val = nil, Step = 0, Ext = 0, Long = true}
      cand.p = {H = GetValueEX(it.p,HIGH,ds), L = GetValueEX(it.p,LOW,ds)}
      if it.l==2 then
         tmp.p = {Val = GetValueEX(it.p,HIGH,ds), Step = Step, Ext = cand.p.H, Long = true}
      end
      if it.l > 2 then
         local Revers = false
         tmp.p.Val = tmp.pp.Val + tmp.pp.Step * (tmp.pp.Ext - tmp.pp.Val)
         tmp.p.Long = tmp.pp.Long
         tmp.p.Ext = tmp.pp.Ext
         tmp.p.Step = tmp.pp.Step
         if tmp.pp.Long then
            if cand.p.L < tmp.p.Val then
               tmp.p = {Val = tmp.pp.Ext, Step = Step, Ext = cand.p.L, Long = false}
               Revers = true
            end
         else
            if cand.p.H > tmp.p.Val then
               tmp.p = {Val = tmp.pp.Ext, Step = Step, Ext = cand.p.H, Long = true}
               Revers = true
            end
         end
         if not Revers then
            cand.pp = {H = GetValueEX(it.pp,HIGH,ds), L = GetValueEX(it.pp,LOW,ds)}
            cand.ppp = {H = GetValueEX(it.ppp,HIGH,ds), L = GetValueEX(it.ppp,LOW,ds)}
            if tmp.pp.Long then
               if cand.p.H > tmp.pp.Ext then
                  tmp.p.Ext = cand.p.H
                  tmp.p.Step = tmp.pp.Step + Step
                  if tmp.p.Step > MaxStep then tmp.p.Step = MaxStep end
               end
               if cand.pp.L < tmp.p.Val then tmp.p.Val = cand.pp.L end
               if cand.ppp.L < tmp.p.Val then tmp.p.Val = cand.ppp.L end
            else
               if cand.p.L < tmp.pp.Ext then
                  tmp.p.Ext = cand.p.L
                  tmp.p.Step = tmp.pp.Step + Step
                  if tmp.p.Step > MaxStep then tmp.p.Step = MaxStep end
               end
               if cand.pp.H > tmp.p.Val then tmp.p.Val = cand.pp.H end
               if cand.ppp.H > tmp.p.Val then tmp.p.Val = cand.ppp.H end
            end
         end
      end
      return tmp.p.Val
   end
return nil
end
end

SMA,MMA,EMA,WMA,SMMA,VMA = "SMA","MMA","EMA","WMA","SMMA","VMA"
OPEN,HIGH,LOW,CLOSE,VOLUME,MEDIAN,TYPICAL,WEIGHTED,DIFFERENCE,ANY = "O","H","L","C","V","M","T","W","D","A"

function CandleExist(I,ds)
return (type(C)=="function" and C(I)~=nil) or
   (type(ds)=="table" and (ds[I]~=nil or (type(ds.Size)=="function" and (I>0) and (I<=ds:Size()))))
end

function Squeeze(I,P)
   return math.fmod(I-1,P+1)
end

function ConvertValue(T,...)
local function r(V, R) 
   if R and string.upper(R)== "ON" then R=0 end
   if V and tonumber(R) then
      if V >= 0 then return math.floor(V * 10^R + 0.5) / 10^R
      else return math.ceil(V * 10^R - 0.5) / 10^R end
   else return V end
end
local arg = {...}
arg.n = select('#', ...)
   if arg.n > 0 then
      for i = 1, arg.n do
         arg[i]=arg[i] and r(arg[i] * ((T and T.Multiply) or 1), (T and T.Round) or "off")
      end
      return table.unpack(arg)
   else return nil end
end


function GetValueEX(I,VT,ds) 
VT=(VT and string.upper(string.sub(VT,1,1))) or ANY
   if VT == OPEN then         --Open
      return (O and O(I)) or (ds and ds:O(I))
   elseif VT == HIGH then       --High
      return (H and H(I)) or (ds and ds:H(I))
   elseif VT == LOW then      --Low
      return (L and L(I)) or (ds and ds:L(I))
   elseif VT == CLOSE then      --Close
      return (C and C(I)) or (ds and ds:C(I))
   elseif VT == VOLUME then      --Volume
      return (V and V(I)) or (ds and ds:V(I)) 
   elseif VT == MEDIAN then      --Median
      return ((GetValueEX(I,HIGH,ds) + GetValueEX(I,LOW,ds)) / 2)
   elseif VT == TYPICAL then   --Typical
      return ((GetValueEX(I,MEDIAN,ds) * 2 + GetValueEX(I,CLOSE,ds))/3)
   elseif VT == WEIGHTED then   --Weighted
      return ((GetValueEX(I,TYPICAL,ds) * 3 + GetValueEX(I,OPEN,ds))/4) 
   elseif VT == DIFFERENCE then   --Difference
      return (GetValueEX(I,HIGH,ds) - GetValueEX(I,LOW,ds))
   else                     --Any
      return (ds and ds[I])
   end
return nil
end
Все индикаторы на Lua
 
Добрый день!
Подскажите где взять indicators.zip под lua 5.4. У меня часть индикаторов на 5.4. и вместе на одном графике они не уживаются с 5.3.
Экспорт ежедневных цен за прошедшие 365 дней, Возможно ли выгрузить и от кого зависит - системы или брокера
 
В продолжении этой темы есть вопрос: Есть ли подобная процедура функция на Lua?
Пользователи Telegram-Bot! Как организовать работу через proxy?
 
Я поставил OpenVPN и купил платный доступ за $1 в месяц.
Вопрос по обработке исключений в Qlua, Вопрос по обработке исключений в Qlua
 
C пиногом разобрался путем

function send_telegram() --если true, то слать телеграм
local handler = io.popen("chcp 861 && ping -n 1 api.telegram.org")
local response = handler:read("*a")
start_pos, end_pos = string.find(response, "Lost = 0" )
if start_pos==nil then telegram=false
  else telegram=true
end
return telegram
end

Все бы ничего, при вызове  io.popen каждый раз кратковременно командное окошко всплывает и перехватывает фокус ввода, то есть Quik на 1 -2 сек становится не главным окном, что очень не хорошо. Как это можно победить запихать вызов пингов в фоновое окно? Может кто уже побеждал?  
Вопрос по обработке исключений в Qlua, Вопрос по обработке исключений в Qlua
 
Добрый день!
Столкнулся с тавой проблемой в Qlua :

Есть следующий код, который успешно работает при отсутствии ошибки.

require"QL"
require 'luanet'
require 'socket'
--вывод в телеграм
luanet.load_assembly "System"
WebClient = luanet.import_type("System.Net.WebClient")
wc = WebClient()
a="Start%20program%20at%20*" .. os.date("%H:%M:%S") .. "*"
PrintDbgStr(a)
wc:DownloadString("https://api.telegram.org/botХХХХХХХХХХХ/sendMessage?chat_id=ХХХХХ..." .. a .. "&parse_mode=Markdown") --значения поменял вывод сообщений в телеграм

Суть кода выводить сообщения в телеграм. До недавного времени все работало успешно, теперь когда РКН блокирует сообщения. QUIK ПОЛНОСТЬЮ ВЫЛЕТАЕТ.
Так как отсутствие коннекта к телеграму предсказать невозможно, то не возможно предсказать, когда вылетит терминал Quik. Нужно искать выход - обработать исключение!

Попробовал использовать

local status, err = pcall(function () www=wc:DownloadString(b .."https://api.telegram.org/botХХХХХХХХХХХХ/sendMessage?chat_id=ХХХХХ...) end)

if err==nil then err="" end -- до этого места доходит пока нет ошибок и в дебагер выдает нормальную информацию
PrintDbgStr(tostring(status) .. " --- " .. err .. " --- " .. www) -- если ошибка в ссылке или тайаут, то квик вылетает и информации в дебагере нет!!!

Вопрос КАК заставить QLUA обработать исключение.
Виды исключений : неправильная ссылка, не верный адрес, хост не доступен???

Проверял послюднюю часть кода в ZeroBrane Studio для Lua - успенно отрабатывает возвращает код ошибки и я могу его обработать.
Помогите разобоаться
Страницы: 1
Наверх