Индикатор осцелятор на загзаге. Если пересекаем синию линию вверх то лонг если вниз, то выход из лонга. Если пересекаем красную линию вниз, то шорт, если пересекаем вверх то выход из шорта
--[[
вопросы к автору: https://t.me/autotrade_ru
параметры:
Proc1 - процент зигзага
--]]
Settings={
Name="ZIG_mult_OSC_v3",
Proc1=2,
Proc2=4,
Up = 0.5,
Dw = -0.5,
line=
{
{
Name = "cur1",
Type =TYPE_LINE,
Width = 2,
Color = RGB(0, 0, 0)
},
{
Name = "cur2",
Type =TYPE_LINE,
Width = 1,
Color = RGB(0, 0, 255)
},
{
Name = "cur3",
Type =TYPE_LINE,
Width = 1,
Color = RGB(255, 0, 0)
}
}
}
function Init()
y1_1 = nil
y2_1 = nil
x1_1 = 1
x2_1 = 1
y1_2 = nil
y2_2 = nil
x1_2 = 1
x2_2 = 1
return 3
end
function OnCalculate(index)
de_1 = Settings.Proc1
vl_1 = C(index)
if index == 1 then
ind_1 = {}
y1_1 = vl_1
y2_1 = vl_1
ind_1[index] = 0
else
ind_1[index] = ind_1[index-1]
if C(index) > y1_1*(1+de_1/100) and y1_1 < y2_1 then
x2_1 = x1_1
y2_1 = y1_1
x1_1 = index
y1_1 = C(index)
ind_1[index] = (C(index) - y2_1*(1+de_1/100))/(y2_1*de_1/100)
else
if C(index) > y1_1 and y1_1 >= y2_1
then
x1_1 = index
y1_1 = C(index)
end
if y1_1 >= y2_1
then
if C(index) > y2_1*(1+de_1/100) then
ind_1[index] = (C(index) - y2_1*(1+de_1/100))/(y2_1*de_1/100)
else
ind_1[index] = 0
end
end
end
if C(index) < y1_1*(1-de_1/100) and y1_1 > y2_1 then
x2_1 = x1_1
y2_1 = y1_1
x1_1 = index
y1_1 = C(index)
ind_1[index] = -(y2_1*(1-de_1/100)-C(index))/(y2_1*de_1/100)
else
if C(index) < y1_1 and y1_1 <= y2_1
then
x1_1 = index
y1_1 = C(index)
end
if y1_1 <= y2_1
then
if C(index) < y2_1*(1-de_1/100) then
ind_1[index] = -(y2_1*(1-de_1/100)-C(index))/(y2_1*de_1/100)
else
ind_1[index] = 0
end
end
end
end
de_2 = Settings.Proc2
vl_2 = C(index)
if index == 1 then
ind_2 = {}
y1_2 = vl_2
y2_2 = vl_2
ind_2[index] = 0
else
ind_2[index] = ind_2[index-1]
if C(index) > y1_2*(1+de_2/100) and y1_2 < y2_2 then
x2_2 = x1_2
y2_2 = y1_2
x1_2 = index
y1_2 = C(index)
ind_2[index] = (C(index) - y2_2*(1+de_2/100))/(y2_2*de_2/100)
else
if C(index) > y1_2 and y1_2 >= y2_2
then
x1_2 = index
y1_2 = C(index)
end
if y1_2 >= y2_2
then
if C(index) > y2_2*(1+de_2/100) then
ind_2[index] = (C(index) - y2_2*(1+de_2/100))/(y2_2*de_2/100)
else
ind_2[index] = 0
end
end
end
if C(index) < y1_2*(1-de_2/100) and y1_2 > y2_2 then
x2_2 = x1_2
y2_2 = y1_2
x1_2 = index
y1_2 = C(index)
ind_2[index] = -(y2_2*(1-de_2/100)-C(index))/(y2_2*de_2/100)
else
if C(index) < y1_2 and y1_2 <= y2_2
then
x1_2 = index
y1_2 = C(index)
end
if y1_2 <= y2_2
then
if C(index) < y2_2*(1-de_2/100) then
ind_2[index] = -(y2_2*(1-de_2/100)-C(index))/(y2_2*de_2/100)
else
ind_2[index] = 0
end
end
end
end
return ind_1[index]+ind_2[index], Settings.Up, Settings.Dw
end<br /><br />