Блог им. autotrade
--[[ AutoTrade target indicator shows target growth varsion 1 line gr shows real growth line tgr shows target growth --]] Settings= { Name = "AT-target_v1", -- indicator name per=20, -- period growth=1.0, -- growth in % xshift=0, -- shifth by x axis line= { { Name = "gr", Type =TYPE_LINE, Width = 1, Color = RGB(0,0,255) }, { Name = "tgr", Type =TYPE_LINE, Width = 1, Color = RGB(255,0,0) } } } function Init() return 2 end function OnCalculate(index) sz = Size() per = Settings.per gr = Settings.growth sh = Settings.xshift if index == sz then for i = 1, sz do -- crearing SetValue(i, 1, nil) SetValue(i, 2, 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) SetValue(i, 1, v) SetValue(i, 2, v2) end -- last value if sh == 0 then return v, v2 end end end