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

Auto Wave Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
thnkbigr
Posted : Friday, January 12, 2018 1:16:13 PM
Platinum Customer Platinum Customer

Joined: 3/31/2006
Posts: 3,207

Bruce 

Can this indicator be plotted in TC? 

'# period = UserInput.Single = 14
'# factor = UserInput.Single = 2.5
'# delay = UserInput.Integer = 5
Static TR As Single
Static ATR As Single
Static termRatio As Single
static Weight As Single
Static sumWeight As Single
Static extreme As Single
Static tstop As Single
Static state As Boolean
Static index As Integer
If isFirstBar Then
TR = Price.High - Price.Low
termRatio = (period - 1) / period
ATR = TR
sumweight = termratio + 1
weight = 1 / sumweight
index = CurrentIndex
If Price.High(-1) - System.Math.Min(Price.Low, Price.Low(-1)) < _
System.Math.Max(Price.High, Price.High(-1)) - Price.Low(-1) Then
extreme = Price.Low
tstop = System.Math.Max(Price.High, extreme + factor * ATR)
state = False
Else
extreme = Price.High
tstop = System.Math.Min(Price.Low, extreme - factor * ATR)
state = True
End If
Else
TR = (Price.High - Price.Low + _
System.Math.Abs(Price.High - Price.Last(1)) + _
System.Math.Abs(Price.Last(1) - Price.Low)) / 2
ATR = ATR * (1 - weight) + weight * TR
sumweight = sumweight * termratio + 1
weight = 1 / sumweight
If state
If Price.Low < tstop AndAlso _
CurrentIndex - index >= delay - 1 Then
AddToOutput(Price.Bar.DateValue(index), extreme)
state = False
extreme = Price.Low
index = CurrentIndex
tstop = System.Math.Max(Price.High, extreme + factor * ATR)
End If
Else
If Price.High > tstop AndAlso _
CurrentIndex - index >= delay - 1 Then
AddToOutput(Price.Bar.DateValue(index), extreme)
state = True
extreme = Price.High
index = CurrentIndex
tstop = System.Math.Min(Price.Low, extreme - factor * ATR)
End If
End If
If state Then
If Price.High >= extreme Then
extreme = Price.High
index = CurrentIndex
End If
tstop = extreme - factor * ATR
Else
If Price.Low <= extreme Then
extreme = Price.Low
index = CurrentIndex
End If
tstop = extreme + factor * ATR
End If
End If
If isLastBar Then AddToOutput(Price.Bar.DateValue(index), extreme)
Plot = Single.NaN
Bruce_L
Posted : Friday, January 12, 2018 2:01:28 PM


Worden Trainer

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

I can't think of a way to do so.



-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.