Блог им. autotrade
--[[ AutoTrade target indicator shows target growth/fall varsion 2 line gr shows real growth line tgr_up shows target growth line tgr_dwn shows target fall --]] Settings= { Name = "AT-target_v2", -- indicator name per=20, -- period growth=1.0, -- growth in % fall=1.0, -- fall in % xshift=0, -- shifth by x axis line= { { Name = "gr", Type =TYPE_LINE, Width = 1, Color = RGB(0,0,0) -- black }, { Name = "tgr_up", Type =TYPE_LINE, Width = 1, Color = RGB(0,0,255) -- blue }, { Name = "tgr_dwn", Type =TYPE_LINE, Width = 1, Color = RGB(255,0,0) -- red } } } function Init() return 3 end function OnCalculate(index) sz = Size() per = Settings.per gr = Settings.growth fl = Settings.growth sh = Settings.xshift if index == sz then for i = 1, sz do -- crearing SetValue(i, 1, nil) SetValue(i, 2, nil) SetValue(i, 3, nil) end for i = sz-per-sh, sz-sh do -- paint line v = (C(sz-sh) - C(sz-per-sh))*(i-(sz-per-sh))/per + C(sz-per-sh) v2 = (C(sz-per-sh)*(1+gr/100) - C(sz-per-sh))*(i-(sz-per-sh))/per + C(sz-per-sh) v3 = -(C(sz-per-sh)*(1+fl/100) - C(sz-per-sh))*(i-(sz-per-sh))/per + C(sz-per-sh) SetValue(i, 1, v) SetValue(i, 2, v2) SetValue(i, 3, v3) end -- last value if sh == 0 then return v, v2, v3 end end end