Пожалуйста. Не судите строго новичка:
Settings = {
Name = "AO_AC_TEST",
round = "off",
Metod = "EMA", --SMA, EMA, VMA, SMMA, VMA
VType = "Median", -- Open, High, Low, Close, Volume, Median, Typical, Weighted, Difference
line = {
{
Name = "Down",
Type = TYPE_TRIANGLE_DOWN,
Color = RGB(255, 0, 0)
},
{
Name = "Up",
Type = TYPE_TRIANGLE_UP,
Color = RGB(0, 255, 0)
}
}
}
function Init()
func = AA()
return #Settings.line
end
function OnCalculate(Index)
return func(Index, Settings)
end
function AA()
local AA_tmp={}
return function (I, Fsettings, ds)
local Fsettings = (Fsettings or {})
local C = C(I) or 0
if I > 40 then
AA_tmp[I] = getCandlesByIndex("AO", 0, I, 1)[0].close or 0
if (AA_tmp[I-2] < AA_tmp[I-1]) and (AA_tmp[I-1] > AA_tmp[I]) and C>0
then
SetValue(I-1, 1, C)
elseif (AA_tmp[I-2] > AA_tmp[I-1]) and (AA_tmp[I-1] < AA_tmp[I]) and C>0
then
SetValue(I-1, 2, C)
end
else
AA_tmp[I] = getCandlesByIndex ("AO", 0, I, 1)[0].close or 0
end
end
end