Блог им. autotrade
--[[ индикатор отрисовки наклонных уровней Параметры: delta - чувствиельность индикатора на волатильность в % rep - количество повторений поиска конечного уровня shif - сдвиг влево конечного бара wt - признак наличия весового коэффициента =0 - без весового =1,2.. - свосовыми коф. чем ближе к концу тем больше show=1, --]] Settings= { Name = "AT-obl_can", -- название индикатора delta=2.0, -- параметр индикатора rep=10, shif=0, wt=1, --hl=1, show=1, line= { { Name = "ln1", Type =TYPE_LINE, Width = 2, Color = RGB(255, 0, 0) }, { Name = "ln2", Type =TYPE_LINE, Width = 2, Color = RGB(255, 0, 0) } } } function Init() vMin = 0 vMax = 0 vMinindex = 0 vMaxindex = 0 voldMinindex = 0 voldMaxindex = 0 return 2 end function OnCalculate(index) rep = Settings.rep shif = Settings.shif wt = Settings.wt --hl = Settings.hl sz = Size()-shif if Settings.show == 1 then if index <= sz then if index <= 1 then vMin = C(index) vMax = C(index) vMinindex = index vMaxindex = index voldMinindex = index voldMaxindex = index v = C(index) else if voldMaxindex >= voldMinindex then if vMin~=nil and C(index)~=nil then if C(index) > (1 + Settings.delta/100)*vMin then vMin = C(index) vMax = C(index) vMaxindex = index voldMinindex = vMinindex vFrom = vMinindex else if vMin > C(index) then vMin = C(index) vMinindex = index vFrom = voldMaxindex else vFrom = vMinindex end end end else if voldMaxindex <= voldMinindex then if vMax~=nil and C(index)~=nil then if C(index) < (1 - Settings.delta/100)*vMax then vMax = C(index) vMin = C(index) vMinindex = index voldMaxindex = vMaxindex vFrom = vMaxindex else if vMax < C(index) then vMax = C(index) vMaxindex = index vFrom = voldMinindex else vFrom = vMaxindex end end end end end --if vFrom~=nil then --[[ for i = vFrom, index do k = (C(index)- C(vFrom))/(index- vFrom); v = i*k + C(index) - index*k SetValue(i, 1, v) end --]] --end if index == sz then for k = 1, 2 do vf = 1 vs = 0 if k == 1 then if vMinindex < vMaxindex then vf = vMinindex vs = vMaxindex up = 0 elseif vMinindex > vMaxindex then vs = vMinindex vf = vMaxindex up = 1 end elseif k == 2 then if voldMinindex < voldMaxindex then vf = voldMinindex vs = voldMaxindex up = 0 elseif voldMinindex > voldMaxindex then vs = voldMinindex vf = voldMaxindex up = 1 end end n = 0 xy = 0 x = 0 y = 0 xx = 0 m = 0 for i = vf, vs do if C(i) ~= nil then m = m +1 n = n + 1*(1+wt*m) xy = xy + i*C(i)*(1+wt*m) x = x + i*(1+wt*m) y = y + C(i)*(1+wt*m) xx = xx + i*i*(1+wt*m) end end if (n*xx - x*x) ~= 0 and n ~= 0 then a = (n*xy - x*y)/(n*xx - x*x) b = (y - a*x)/n for j = 1, rep do n = 0 xy = 0 x = 0 y = 0 xx = 0 m = 0 for i = vf, vs do if C(i) ~= nil then v = a*i + b clc = 0 if up == 1 and C(i) >= v then clc = 1 end if up == 0 and C(i) <= v then clc = 1 end if clc == 1 then m = m + 1 n = n + 1*(1+wt*m) --[[ if up == 1 and hl == 1 then xy = xy + i*H(i)*(1+wt*m) elseif up == 0 and hl == 1 then xy = xy + i*L(i)*(1+wt*m) else --]] xy = xy + i*C(i)*(1+wt*m) -- end x = x + i*(1+wt*m) --[[ if up == 1 and hl == 1 then y = y + H(i)*(1+wt*m) elseif up == 0 and hl == 1 then y = y + L(i)*(1+wt*m) else --]] y = y + C(i)*(1+wt*m) -- end xx = xx + i*i*(1+wt*m) end end end --[[--]] if (n*xx - x*x) ~= 0 and n ~= 0 and n >= 2 then a = (n*xy - x*y)/(n*xx - x*x) b = (y - a*x)/n --[[ --]] end end for i = vf, sz do v = a*i + b if up == 1 and v >= C(vs) or up == 0 and v <= C(vs) then SetValue(i, k, v) end end end end end end end end end
в квике есть еще настройка отображать скрипты старые
smart-lab.ru/blog/820658.php