Settings={ Name="ADAPTMA", n=5, m=10, line= { --[[ { Name = "cur1", Type =TYPE_LINE, Width = 1, Color = RGB(0,0, 0) }, { Name = "cur2", Type =TYPE_LINE, Width = 1, Color = RGB(0,0, 0) }, { Name = "cur3", Type =TYPE_LINE, Width = 1, Color = RGB(0,0, 0) }, { Name = "cur4", Type =TYPE_LINE, Width = 1, Color = RGB(0,0, 0) }, { Name = "cur5", Type =TYPE_LINE, Width = 1, Color = RGB(0,0, 0) }, --]] { Name = "cur6", Type =TYPE_LINE, Width = 1, Color = RGB(255,0, 0) } } } --[[ -- кривая сдвига описание свойств: delta: сдвиг в барах от цены вправо --]] function Init() ma={} val={} return 1 end function OnCalculate(index) n = Settings.n m = Settings.m ma[index]={} val[index]={} for i=1, n do if index > 1 then if ma[index-1][i] ~= nil then ma[index][i] = ma[index-1][i] + O(index) else ma[index][i] = O(index) end else ma[index][i] = O(index) end period = i*10 if index - period > 1 then if ma[index-period][i] ~= nil then val[index][i] = (ma[index][i] - ma[index-period][i])/period else val[index][i] = ma[index][i] end else val[index][i] = nil end end k = n p = 0 for j=n, 1,-1 do e = 0 pj = 0 if index-m > 1 then for i=index-m, index-1 do if val[i-1][j] ~= nil and val[i][j] ~= nil then if ( val[i-1][j] <= O(i-1) and val[i][j] > O(j) or val[i-1][j] >= O(i-1) and val[i][j] < O(j) ) then e = e + 1 end end end pj = -O(index)*0.001*e if O(index) >= O(index-m) then pj = O(index) - O(index-m) + pj else pj = O(index-m) - O(index) + pj end end if pj > p then p = pj k = j end end val[index][n+1] = val[index][k] --return ma[index] -- return val[index][1], val[index][2], val[index][3], val[index][4], val[index][5], val[index][6] return val[index][n+1] --[[ val[1] ={} val[1][index] = 9 return val[1][index] --]] end
Settings={ Name="VDIV", period=20, periodma=15, line= { { Name = "cur1", Type =TYPE_LINE, Width = 1, Color = RGB(255,0,0) }, { Name = "cur2", 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 3 end function OnCalculate(index) sumv1 = 0 sumv2 = 0 if index >= Settings.period then for i=index-Settings.period+1, index do if V(i) ~= nil and C(i) ~= nil then if C(i) > O(i) then sumv1 = sumv1+V(i)*(C(i) - O(i)) else sumv2 = sumv2+V(i)*(O(i) - C(i)) end end end else sumv1 = nil sumv2 = nil end if sumv2 ~= 0 and sumv2 ~= nil then vdiv = sumv1/sumv2 vdiv2 = sumv2/sumv1 vdiv3 = vdiv - vdiv2 else vdiv = nil vdiv2 = nil vdiv3 = nil end mas[index] = vdiv3 ma = 0 if index >= Settings.periodma then for i=index-Settings.periodma+1, index do if mas[i] ~= nil then ma = ma + mas[i] end end end ma = ma/Settings.periodma return ma, 0 end
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
Settings={ Name="VCUR", period=20, weighted=0, line= { { Name = "cur1", Type =TYPE_LINE, Width = 2, Color = RGB(140,181, 242) } } } --[[ -- кривая объемов описание свойств: period: сколько баров берутся в подсчет weighted: =0 - обычная, =1 - взвешанная --]] function Init() sumv = 0 return 1 end function OnCalculate(index) 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 if C(i-1) > O(i-1) then if Settings.weighted == 0 then sumv = sumv + V(i-1) else sumv = sumv + V(i-1)*(i-(index-Settings.period))/Settings.period end else if Settings.weighted == 0 then sumv = sumv - V(i-1) else sumv = sumv - V(i-1)*(i-(index-Settings.period))/Settings.period end end end end else sumv = nil end return sumv end