FisherN

Posted By: rki

FisherN - 04/11/23 08:36

Here is my Python implementaton of FisherN

def FisherN (Data, Len):
out=np.ones (len(Data))*Data
Value1=0
Fish=0
for i in range (len(out)):
Period = i+Len
Period = Period if Period < len(out) else len(out)
MaxH=max (Data[i:i+Len])
MinL=min (Data[i:i+Len])
if MaxH>MinL:
fish=2.0*(Data[i]-MinL)/(MaxH-MinL)-1
else:
fish=0
Value1=0.33*2*(fish-0.5)+0.67*Value1
if Value1 > 0.999:
Value1=0.999
if Value1 <-0.999:
Value1=-0.999
Fish=0.5*Fish+0.5*np.log((1+Value1)/(1-Value1))
out[i]=Fish
return out


This was the corresponding implementation in Zorro

// normalize a value to the -1..+1 range
var Normalize(var* Data,int Period)
{
Period = Max(2,Period);
var vMin = MinVal(Data,Period);
var vMax = MaxVal(Data,Period);
if(vMax>vMin)
return 2.*(*Data-vMin)/(vMax-vMin) - 1.;
else return 0.;
}

// Fisher Transform
var Fisher(var* Data)
{
var v = Clamp(Data[0],-0.998,0.998);
return 0.5*log((1.+v)/(1.-v));
}

// Normalized Fisher transform
var FisherN(var* Data,int Period)
{
var *Value = series(*Data,2), *FN = series(*Data,2);
Value[0] = 0.33*Normalize(Data,Period) + 0.67*Value[1];
return FN[0] = Fisher(Value) + 0.5*FN[1];
}
Posted By: rki

Re: FisherN - 04/11/23 08:38

My questions are:
1. Do you agree that the implementation is right as Zorro/meaning same as Zorro
2.
Why do we normalize as 2*(x-xmin)/(xmax-xmin)-1 instead of just (x-xmean)/sigma . I see that the results vary due to this.
© 2024 lite-C Forums