Settings={ Name="VCUR", period=50, periodma=15, weighted=1, weightedma=1, proportional=1, line= { { Name = "cur1", Type =TYPE_LINE, Width = 1, Color = RGB(155,0, 0) }, { Name = "cur2", Type =TYPE_LINE, Width = 1, Color = RGB(0,0,155) }, { Name = "cur3", Type =TYPE_LINE, Width = 1, Color = RGB(0,0, 0) } } } --[[ -- кривая объемов описание свойств: period: сколько баров берутся в подсчет weighted: =0 - обычная, =1 - взвешанная proportional: =1- считается: volume*(close-open)/(hight-low), =0 - считается: volume*sign(close-open) --]] function Init() mas={} return 2 end function OnCalculate(index) sumv = 0 wsum = 0 if index >= Settings.period then for i=index-Settings.period+1, index do if sumv == nil then sumv = 0 end if C(i-1) ~= nil then wsum = wsum + i-(index-Settings.period) if C(i-1) > O(i-1) then if Settings.proportional == 0 then prop = 1 else if (H(i-1)-L(i-1)) == 0 then prop = 0 else prop = (C(i-1)-O(i-1))/(H(i-1)-L(i-1)) end end if Settings.weighted == 0 then sumv = sumv + prop*V(i-1) else sumv = sumv + prop*V(i-1)*(i-(index-Settings.period))--/Settings.period end else if Settings.proportional == 0 then prop = 1 else if (H(i-1)-L(i-1)) == 0 then prop = 0 else prop = (O(i-1)-C(i-1))/(H(i-1)-L(i-1)) end end if Settings.weighted == 0 then sumv = sumv - prop*V(i-1) else sumv = sumv - prop*V(i-1)*(i-(index-Settings.period))--/Settings.period end end end end else sumv = nil end if Settings.weighted ~= 0 then if sumv ~= nil then sum =sumv/wsum end end mas[index]=sumv ma = 0 wsum = 0 if index >= Settings.periodma then for i=index-Settings.periodma+1, index do if mas[i] ~= nil then wsum = wsum + i-(index-Settings.periodma) if Settings.weightedma == 0 then ma = ma + mas[i] else ma = ma + mas[i]*(i-(index-Settings.periodma))--/Settings.periodma end end end end if Settings.weightedma == 0 then if ma ~= nil then ma = ma/Settings.periodma end else ma = ma/wsum end return sumv, ma--, 0 end