Избранное трейдера protorus
--[[ MA volumn up down --]] Settings= { Name = "MAV2_m", -- indicator name per=10, -- period line= { { Name = "MA", Type =TYPE_LINE, Width = 1, Color = RGB(0,0,0) }, { Name = "MA2", Type =TYPE_LINE, Width = 1, Color = RGB(0,0,255) } } } function Init() mav1 = {} mav2 = {} return 2 end function OnCalculate(index) per = Settings.per if index > 1 then curv = C(index) prevv = C(index-1) else curv = C(index) prevv = C(index) end if curv - prevv > 0 then if index > 1 then mav1[index] = mav1[index-1] + V(index) mav2[index] = mav2[index-1] else mav1[index] = V(index) mav2[index] = 0 end else if index > 1 then mav1[index] = mav1[index-1] mav2[index] = mav2[index-1] + V(index) else mav1[index] = 0 mav2[index] = V(index) end end if index > per then vv1 = mav1[index] - mav1[index-per] vv2 = mav2[index] - mav2[index-per] else vv1 = 0 vv2 = 0 end return 0, vv1 - vv2 end
--[[ MA volumn up down --]] Settings= { Name = "MAV2", -- indicator name per=10, -- period line= { { Name = "MA", Type =TYPE_LINE, Width = 1, Color = RGB(0,0,255) }, { Name = "MA2", Type =TYPE_LINE, Width = 1, Color = RGB(255,0,0) } } } function Init() mav1 = {} mav2 = {} return 2 end function OnCalculate(index) per = Settings.per if index > 1 then curv = C(index) prevv = C(index-1) else curv = C(index) prevv = C(index) end if curv - prevv > 0 then if index > 1 then mav1[index] = mav1[index-1] + V(index) mav2[index] = mav2[index-1] else mav1[index] = V(index) mav2[index] = 0 end else if index > 1 then mav1[index] = mav1[index-1] mav2[index] = mav2[index-1] + V(index) else mav1[index] = 0 mav2[index] = V(index) end end if index > per then vv1 = mav1[index] - mav1[index-per] vv2 = mav2[index] - mav2[index-per] else vv1 = 0 vv2 = 0 end return vv1, vv2 end