Блог им. autotrade
--[[ SMA list template v1 --]] Settings= { Name = "SMA_list_magic_template_v3", -- indicator name ln1=10, -- period ln2=20, -- period ln3=30, -- period ln4=40, -- period ln5=50, -- period ln6=60, -- period ln7=70, -- period ln8=80, -- period ln9=90, -- period ln10=100, -- period line= { { Name = "SMA_TEMPL", Type =TYPE_LINE, Width = 1, Color = RGB(0,0,0) }, { Name = "SMA_TEMPL", Type =TYPE_LINE, Width = 1, Color = RGB(255,0,0) } } } function Init() sma = {{},{}} sum = {{},{}} ln = {} n = {} m = {} sumln = 0 return 2 end function GetSMA(index, num) if index == 1 then if num == 1 then ln[num] = Settings.ln1 end if num == 2 then ln[num] = Settings.ln2 end if num == 3 then ln[num] = Settings.ln3 end if num == 4 then ln[num] = Settings.ln4 end if num == 5 then ln[num] = Settings.ln5 end if num == 6 then ln[num] = Settings.ln6 end if num == 7 then ln[num] = Settings.ln7 end if num == 8 then ln[num] = Settings.ln8 end if num == 9 then ln[num] = Settings.ln9 end if num == 10 then ln[num] = Settings.ln10 end sumln = sumln + ln[num] sum[num] = {} sum[num][index] = O(index) n[num]=1 else if index > ln[num] then sum[num][index] = sum[num][index-1] + O(index) sum[num][index] = sum[num][index] - O(index-ln[num]) else sum[num][index] = sum[num][index-1] + O(index) n[num] = n[num] + 1 end end if n[num] ~= 0 then if num == 1 then sma[index] = {} end sma[index][num] = sum[num][index]/n[num] end return sma[index][num] end function GetMagic(index, num) res = 0 val = 0 cnt = 3+num if index > ln[num] then val = sma[index][num] for i = 1, cnt do val = val + (O(index) - O(index-ln[num]+i))/ln[num] if O(index) >= val or val >= sma[index][num] then res = res + (ln[num]/sumln)*(i/cnt) end if O(index) < val or val < sma[index][num] then res = res - (ln[num]/sumln)*(i/cnt) end end end return res end function OnCalculate(index) GetSMA(index, 1) GetSMA(index, 2) GetSMA(index, 3) GetSMA(index, 4) GetSMA(index, 5) GetSMA(index, 6) GetSMA(index, 7) GetSMA(index, 8) GetSMA(index, 9) GetSMA(index, 10) m[index] = GetMagic(index, 1) m[index] = m[index] + GetMagic(index, 2) m[index] = m[index] + GetMagic(index, 3) m[index] = m[index] + GetMagic(index, 4) m[index] = m[index] + GetMagic(index, 5) m[index] = m[index] + GetMagic(index, 6) m[index] = m[index] + GetMagic(index, 7) m[index] = m[index] + GetMagic(index, 8) m[index] = m[index] + GetMagic(index, 9) m[index] = m[index] + GetMagic(index, 10) if index > 10 then return 0, (5*m[index]+4*m[index-1]+3*m[index-2]+2*m[index-3]+m[index-4])/15 else return 0, nil end end
есть такая программа QUIK на него ставится