Блог им. autotrade
--[[ параметры: Procent - процент зигзага --]] Settings={ Name="ZIG_PORTFOLIO", Procent=2, line= { { Name = "cur1", Type =TYPE_LINE, Width = 2, Color = RGB(0,0, 0) } } } function Init() plus = 0 minus = 0 y1 = nil y2 = nil x1 = 1 x2 = 1 return 1 end function OnCalculate(index) de = Settings.Procent vl = C(index) if index == 1 then y1 = vl y2 = vl else if C(index) > y1*(1+de/100) and y1 < y2 then minus = minus + (x1-x2)*(y2-y1) x2 = x1 y2 = y1 x1 = index y1 = C(index) else if C(index) > y1 and y1 >= y2 then x1 = index y1 = C(index) end end if C(index) < y1*(1-de/100) and y1 > y2 then plus = plus + (x1-x2)*(y1-y2) x2 = x1 y2 = y1 x1 = index y1 = C(index) else if C(index) < y1 and y1 <= y2 then x1 = index y1 = C(index) end end end vl=0 if minus~=0 then vl=plus/minus end return vl end