Trying to create Volume Flow Indicator with RealCode.
Plot vcp then drag it to indicator to calculate vfi.
Then drag vfi to indicator to calculate vfima.
Then plot vfi  vfima
I have a problem at StdDev step. SumC & SumSq are zero.
Can you help me? or is there a better way? Trying to get RealCode version that gives similar zero crosses to your TC2000 code.
'# Length = UserInput.Integer = 130
'# coef = UserInput.Integer = .2
'# vcoef = UserInput.Integer = 2.5
Dim inter As Single
Dim typical As Single
Dim typical1 As Single
Dim vinter As Single
Dim cutoff As Single
Dim vave As Single
Dim vmax As Single
Dim vc As Single
dim mf as Single
Dim vcp As Single
Dim vfi As Single
Dim vfima As Single
Dim d As Single
Dim signallength As Single = 5
Static SumC As Single
Static SumSq As Single
If isFirstBar Then
SumC = 0
SumSq = 0
End If
'typical = hlc3
'inter = log(typical)  log(typical[1] )
'vinter = stdev(inter, 30)
'cutoff = coef * vinter * close
'vave = sma(volume, length)[1]
'vmax = vave * vcoef
'vc = iff(volume < vmax, volume, vmax) //min(volume, vmax)
'mf = typical  typical[1]
'vcp = iff(mf > cutoff, vc, iff(mf < cutoff, vc, 0))
'vfi = ma(sum(vcp, length) / vave, 3)
'vfima = ema(vfi, signalLength)
'd = vfi  vfima
typical = (price.High + price.Low + price.Close) / 3
typical1 = (price.high(1) + price.Low(1) + price.Close(1)) / 3
inter = system.Math.Log(typical)  system.Math.Log(typical1)
'vinter = stdev(inter, 30)
'# Period = UserInput.Integer = 30
SumC += inter
SumSq += inter ^ 2
If CurrentIndex >= Period Then
SumC = inter
SumSq = inter ^ 2
End If
If CurrentIndex >= Period  1 Then
vinter = system.Math.abs((SumSq  SumC ^ 2 / Period) / Period) ^ .5
Else
vinter = Single.NaN
End If
vave = volume.AVGC(length, 1)
vmax = vave * vcoef
'vc = iff(volume < vmax, volume, vmax) //min(volume, vmax)
If volume.Close < vmax Then
vc = volume.close
Else
vc = vmax
End If
cutoff = coef * vinter * price.close
vave = volume.AVGC(length, 1)
vmax = vave * vcoef
If volume.close < vmax Then
vc = volume.close
Else
vc = vmax
End If
mf = typical  typical1
If mf > cutoff Then
vcp = vc
Else If mf < cutoff Then
vcp = vc
Else
vcp = 0
End If
plot = vcp
'vfi = ma(sum(vcp, length) / vave, 3)
'vfima = ema(vfi, signalLength)
'd = vfi  vfima
