'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'John B Version of Elhers Mesa Stochastic made from Easy Language posted on the OTPro Forum by Wolf
'This Conversion is my first so please beware I have guessed my way through with a little trial and error!
'This may need revision but it appears OK. John B
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Indicator
# Param "LengthJFESto",20,1,50
Dim Alpha1,HP,A1,B1,C1,C2,C3,Filt,HighestC,LowestC,Count,Stoc,MesaStochastic as single
'Highpass filter cyclic components whoes periods are shorter than 48 bars
If Bar > 0 Then
Count += 1
End if
If Count = LengthJFESto then
Count = 0
End if
if bar > LengthJFESto then
Alpha1 = (cos(.707*6.2832/48) + Sin(.707*6.2832/48)-1)/Cos(.707*6.2832/48)
HP = (1-Alpha1 /2)*(1-Alpha1 /2)*(C -2*C[1]+C[2]) + 2 *(1-Alpha1) * HP[1]- (1-Alpha1)*(1-Alpha1) * HP[2]
'Smooth with a super Smoother Filter
A1 = Exp(-1.414*3.14159/10)
B1 = 2*a1* Cos(1.414*3.14159/10)
C2 = B1
C3 = -A1*A1
C1 = 1-C2-C3
Filt = C1*(HP+HP[1])/2 + C2*Filt[1]+C3*Filt[2]
HighestC = Filt
LowestC = Filt
For Count = 0 to LengthJFESto -1
If Filt[Count] > HighestC then
HighestC = Filt[Count]
end if
If Filt[Count] < LowestC then
LowestC = Filt[Count]
End if
Next
Stoc = (Filt - LowestC) / (HighestC - LowestC)
MesaStochastic = C1 * (Stoc + Stoc[1]) /2 + C2* MesaStochastic[1] + C3 * MesaStochastic[2]
Plot("MesaSto",MesaStochastic)
Plot("Myup",.8,gray)
Plot("MyDn",.2,gray)
end if
Return MesaStochastic ' Return the value calculated by the indicator