Тема: Fisher
Фишер, например
dofile(getWorkingFolder() .. "\\Include\\tech.lua")
function FISHER()
local cache_fisher={}
local cache_value={}
return function(ind, p, v_t)
local dv = dValue
local period = p
local v_type = v_t
local index = ind
local price=dv(index,v_type);
local MaxH = price;
local MinL = price;
local k =0
local pr=0
local mx = high
local mn = low
local value = 0
local result = 0
if index == 1 then
cache_fisher = {}
cache_value = {}
end
if index < period then
cache_fisher[index] = 0
cache_value[index] = 0
return nil
end
MaxH = mx(index-period,index,v_type)
MinL = mn(index-period,index,v_type)
local res=MaxH-MinL
if (res) then
value=0.33*2.0*((price-MinL)/res-0.5)+0.67*cache_value[index-1];
else
value=0
end
if(value>(0.9999)) then value= (0.9999) end
if(value<(-0.9999)) then value= (-0.9999) end
result = 0.5*math.log((1+value)/(1-value))+0.5*cache_fisher[index-1]
cache_value[index]=value
cache_fisher[index]= result
return result
end
end
function high(_start, _end, v_type)
local H=dValue(_start, v_type)
for i = _start+1, _end do
if(dValue(i, v_type)>H) then
H=dValue(i, v_type)
end
end
return H
end
function low(_start, _end, v_type)
local L=dValue(_start, v_type)
for i = _start+1, _end do
if(dValue(i, v_type)<L) then
L=dValue(i, v_type)
end
end
return L
end
dofile(getWorkingFolder() .. "\\Include\\os.lua")
Settings =
{
Name = "Fisher",
period = 27,
value_type = "M",
line= {
{
Name = "Fisher",
Color = RGB(180, 200, 240),
Type = TYPE_HISTOGRAM,
Width = 2
}
}
}
function Init()
myFisher = FISHER()
return 1
end
function OnCalculate(index)
local Fish = myFisher(index, Settings.period,Settings.value_type)
return Fish
end