Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

VFI (Volume Flow Indicator) Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
cliffhanger31
Posted : Monday, July 18, 2011 2:34:10 PM
Registered User
Joined: 8/24/2007
Posts: 43
Do we have access to Real Code for this indicator? It is referenced in this months Stocks and Commodities Magazine issue.

Andreas Wiedenfeld
Bruce_L
Posted : Monday, July 18, 2011 4:30:11 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
It is not RealCode, but you should be able to Open an attached Indicator directly into a running copy of StockFinder 5 (and save it from within StockFinder 5 if desired). You could also Save it to the \My Documents\StockFinder5\(Your Username)\My Indicators\ folder and then load it like you would any other Indicator (or Copy and Paste it there from wherever it Saves if you can't specify the destination directory when Saving).

Attachments:
Volume Flow Indicator VFI.sfInd - 11 KB, downloaded 1,115 time(s).



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
cliffhanger31
Posted : Tuesday, July 19, 2011 8:20:26 AM
Registered User
Joined: 8/24/2007
Posts: 43
Thank you Sir, as always!
Fisher2
Posted : Tuesday, December 26, 2017 8:35:49 PM
Gold Customer Gold Customer

Joined: 8/13/2009
Posts: 73

Bruce,

Can a PCF now be written in TC2000 for the Volume Flow Indicator?  There is information on its coding at www.mkatsanos.com/VFI.html (I could not get the address to link, and I could not get the code to paste).

If the code can be written in TC2000 would you be so kind?

Thank you,

Fisher2

 

Bruce_L
Posted : Wednesday, December 27, 2017 10:51:28 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

This is what I have come up with for TC2000 v17+.

XAVG(IIF(AVGV130.1 > 0, SUM(IIF(ABS(H + L + C - H1 - L1 - C1) / 3 > .2 * SQR(ABS((SUM((LOG((H + L + C) / 3) - LOG((H1 + L1 + C1) / 3)) ^ 2, 30) - SUM(LOG((H + L + C) / 3) - LOG((H1 + L1 + C1) / 3), 30) ^ 2 / 30) / 30)) * C, SGN(H + L + C - H1 - L1 - C1) * LEAST(V, AVGV130.1 * 2.5), 0) , 130) / AVGV130.1, 0), 3)

But it isn't matching up with StockFinder (seems to be upside down and the off by some factor), so one of them is wrong.



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Fisher2
Posted : Wednesday, December 27, 2017 12:37:03 PM
Gold Customer Gold Customer

Joined: 8/13/2009
Posts: 73

Thanks Bruce, I have been using it as an indicator on ThinkorSwim, but was wanting to see if I could get in on TC2k as scanning is so much more to my liking.  I'll be able to compare it to the one on TOS to see if it is showing the same values or acting the same way as the one on TOS.

Thanks for your help,

Fisher2

Fisher2
Posted : Wednesday, December 27, 2017 12:48:44 PM
Gold Customer Gold Customer

Joined: 8/13/2009
Posts: 73

Bruce, after looking at a few charts the readings are a bit different at any given time but the dates of crosses above and below zero are very close and seem fairly consistent though not exact.  I think it is close enough and good enough for my purposes.

Thanks so much.

Fisher2

 

maljester
Posted : Wednesday, January 10, 2018 2:36:59 PM
Platinum Customer Platinum Customer

Joined: 1/30/2005
Posts: 135

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

 

maljester
Posted : Wednesday, January 10, 2018 7:58:35 PM
Platinum Customer Platinum Customer

Joined: 1/30/2005
Posts: 135

Changed StdDev code to the following and am getting a value but vcp is zero

If isFirstBar Then
     SumC = 0
     SumSq = 0
Else If CurrentIndex > Period Then
     SumC -= inter
     SumSq -= inter ^ 2
Else
     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
Bruce_L
Posted : Thursday, January 11, 2018 11:19:16 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

What is your complete RealCode after the changes?



-Bruce
Personal Criteria Formulas
TC2000 Support Articles
maljester
Posted : Thursday, January 11, 2018 4:03:20 PM
Platinum Customer Platinum Customer

Joined: 1/30/2005
Posts: 135

I don't think my StdDev code is correct

maljester
Posted : Thursday, January 11, 2018 4:12:41 PM
Platinum Customer Platinum Customer

Joined: 1/30/2005
Posts: 135

code after StdDev logic change

'# 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
 
'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 = log(typical) - log(typical[1] )
inter = system.Math.Log(typical) - system.Math.Log(typical1)
'vinter = stdev(inter, 30)
'# Period = UserInput.Integer = 30
 
If isFirstBar Then
     SumC = 0
     SumSq = 0
Else If CurrentIndex > Period Then
     SumC -= inter
     SumSq -= inter ^ 2
Else
     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
cutoff = coef * vinter * price.close
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
 
mf = typical - typical1
If mf > cutoff Then
     vcp = vc
Else If mf < cutoff Then
     vcp = -vc
Else 
     vcp = 0
End If
plot = vcp
maljester
Posted : Thursday, January 11, 2018 4:20:43 PM
Platinum Customer Platinum Customer

Joined: 1/30/2005
Posts: 135

Is it possible to just translate the TC2000 code to RealCode?

XAVG(IIF(AVGV130.1 > 0, SUM(IIF(ABS(H + L + C - H1 - L1 - C1) / 3 > .2 * SQR(ABS((SUM(LOG((H + L + C) / 3) - LOG((H1 + L1 + C1) / 3), 30) - SUM(LOG((H + L + C) / 3) - LOG((H1 + L1 + C1) / 3), 30) ^ 2 / 30) / 30)) * C, SGN(H + L + C - H1 - L1 - C1) * LEAST(V, AVGV130.1 * 2.5), 0) , 130) / AVGV130.1, 0), 3)
 

 

maljester
Posted : Thursday, January 11, 2018 4:31:46 PM
Platinum Customer Platinum Customer

Joined: 1/30/2005
Posts: 135
"Else If mf < cutoff then" in prior post s/b 
Else If mf < -cutoff Then
but this make vcp zero
 
 
'# 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
 
'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 = log(typical) - log(typical[1] )
inter = system.Math.Log(typical) - system.Math.Log(typical1)
'vinter = stdev(inter, 30)
'# Period = UserInput.Integer = 30
 
If isFirstBar Then
SumC = 0
SumSq = 0
Else If CurrentIndex > Period Then
SumC -= inter
SumSq -= inter ^ 2
Else
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
cutoff = coef * vinter * price.close
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
 
mf = typical - typical1
If mf > cutoff Then
vcp = vc
Else If mf < -cutoff Then
vcp = -vc
Else 
vcp = 0
End If
plot = vcp
Bruce_L
Posted : Friday, January 12, 2018 4:14:40 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138

I think the original PCF was missing a ^ 2. When this is added I get the following.

XAVG(IIF(AVGV130.1 > 0, SUM(IIF(ABS(H + L + C - H1 - L1 - C1) / 3 > .2 * SQR(ABS((SUM((LOG((H + L + C) / 3) - LOG((H1 + L1 + C1) / 3)) ^ 2, 30) - SUM(LOG((H + L + C) / 3) - LOG((H1 + L1 + C1) / 3), 30) ^ 2 / 30) / 30)) * C, SGN(H + L + C - H1 - L1 - C1) * LEAST(V, AVGV130.1 * 2.5), 0) , 130) / AVGV130.1, 0), 3)

I have come up with the following RealCode Indicator which seems to match the altered PCF.

'|******************************************************************
'|*** StockFinder RealCode Indicator - Version 5.0 www.worden.com 
'|*** Copy and paste this header and code into StockFinder *********
'|*** Indicator:Volume Flow Indicator (VFI)
'|******************************************************************
'#Cumulative
'# Length = UserInput.Integer = 130
'# coef = UserInput.Single = 0.2
'# vcoef = UserInput.Single = 2.5
'# SDper = UserInput.Integer = 30
'# Smooth = UserInput.Single = 3
Static Typical As New List(Of Single)
Static LogTyp As New List(Of Single)
Static Sum As Single
Static SumSq As Single
Static Past As New List(Of Single)
Static PastSum As Single
Static EMA As Single
Static sumWeight As Single
Static termRatio As Single
If isFirstBar Then
	Typical.Clear
	LogTyp.Clear
	Sum = 0
	SumSq = 0
	Past.Clear
	PastSum = 0
End If
Typical.Insert(0, (Price.High + Price.Low + Price.Close) / 3)
LogTyp.Insert(0, Math.Log(Typical(0)))
If Typical.Count >= 2 Then
	Sum += LogTyp(0) - LogTyp(1)
	SumSq += (LogTyp(0) - LogTyp(1)) ^ 2
End If
If Typical.Count >= SDPer Then
	If Math.Abs(Typical(0) - Typical(1)) > Price.Last * _
		coef * Math.Abs((SumSq - Sum ^ 2 / SDper) / SDper) ^ .5 Then
		Past.Insert(0, Math.Sign(Typical(0) - Typical(1)) * Math.Min(Volume.Value, Volume.AVG(Math.Min(CurrentIndex, Length), 1) * 2.5))
		PastSum += Past(0)
	Else
		Past.Insert(0, 0)
	End If
	Sum -= LogTyp(SDper - 1) - LogTyp(SDper)
	SumSq -= (LogTyp(SDper - 1) - LogTyp(SDper)) ^ 2
End If
If Past.Count > Length Then
	Dim Weight As Single = 1 / sumWeight
	EMA = EMA * (1 - Weight) + Weight * PastSum / Volume.AVG(Length, 1)
	sumWeight = sumWeight * termRatio + 1
	PastSum -= Past(Length - 1)
	Plot = EMA
Else If Past.Count = Length Then
	EMA = PastSum / Volume.AVG(Length, 1)
	termRatio = (Smooth - 1) / (Smooth + 1)
	sumWeight = termRatio + 1
	PastSum -= Past(Length - 1)
	Plot = EMA
Else
	Plot = Single.NaN
End If
If isLastBar Then
	Typical.Clear
	LogTyp.Clear
	Sum = 0
	SumSq = 0
	Past.Clear
	PastSum = 0
End If


-Bruce
Personal Criteria Formulas
TC2000 Support Articles
Users browsing this topic
Guest-1

Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.