Доработал свой предыдущий zigzag чтоб работал быстрее
название нового индикатора zigzag2
скачать можно здесь:
https://dropmefiles.com/5EOWp
как выглядит:
код индикатора:
Settings=
{
Name = "Zigzag2", -- название индикатора
delta=2, -- параметр индикатора
line=
{
{
Name = "zigzagline2",
Type =TYPE_LINE,
Width = 2,
Color = RGB(120,90, 140)
}
}
}
function Init()
vMin = 0
vMax = 0
vMinindex = 0
vMaxindex = 0
voldMinindex = 0
voldMaxindex = 0
return 1
end
function OnCalculate(index)
local printz = 0
if index == 1 then
vMin = C(index)
vMax = C(index)
vMinindex = index
vMaxindex = index
voldMinindex = index
voldMaxindex = index
ve = C(index)
else
if voldMaxindex >= voldMinindex then
if C(index) > (1 + Settings.delta/100)*vMin then
vMin = C(index)
vMax = C(index)
vMaxindex = index
voldMinindex = vMinindex
vFrom = voldMaxindex
vTo = vMinindex
printz = 1
else
if vMin > C(index) then
vMin = C(index)
vMinindex = index
vFrom = voldMaxindex
vTo = index
printz = 0
else
vFrom = vMinindex
vTo = index
printz = 0
end
end
else
if voldMaxindex <= voldMinindex then
if C(index) < (1 - Settings.delta/100)*vMax then
vMax = C(index)
vMin = C(index)
vMinindex = index
voldMaxindex = vMaxindex
vFrom = voldMinindex
vTo = vMaxindex
printz = 1
else
if vMax < C(index) then
vMax = C(index)
vMaxindex = index
vFrom = voldMinindex
vTo = index
printz = 0
else
vFrom = vMaxindex
vTo = index
printz = 0
end
end
end
end
if (printz == 1) or (Size() == index) then
for i = vFrom, vTo do
k = (C(vTo)- C(vFrom))/(vTo- vFrom);
v = i*k + C(vTo) - vTo*k
SetValue(i, 1, v)
ve = v
end
if (Size() == index) then
ve = C(index)
if voldMaxindex >= voldMinindex then
vFrom = voldMaxindex
vTo = vMinindex
end
if voldMaxindex <= voldMinindex then
vFrom = voldMinindex
vTo = vMaxindex
end
for i = vFrom, vTo do
k = (C(vTo)- C(vFrom))/(vTo- vFrom);
v = i*k + C(vTo) - vTo*k
SetValue(i, 1, v)
end
end
end
end
return ve
end
эта тема обсуждалась поищи на форуме
smart-lab.ru/blog/530133.php
https://www.youtube.com/watch?v=VjWPUWmS34o