Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 7/13/2008 Posts: 35
|
I've read a couple of past discussions on this forum regarding an ATR stop indicator and didn't really come up with what I was looking for, but very close.
I found an indicator that plots the price plus or minus some multiple of it's ATR. I then added a Min or Max of Line indicator to it and got a rough approximation of a long/short trailing stop indicator, but there's a problem; because of the nature of the Max or Min of Line indicator, the trailing stop is able to drop as data from it's selcted period is lost (and similarly rise if plotted above price).
I'm looking to create a parabolic support and resistance-type indicator that flips between "long" and "short" in which the Max and Min of Line period begins at that particular point. I'm not sure how else to explian this one... Any thoughts?
Thank you as always,
RDJ
|
|
Administration
Joined: 9/30/2004 Posts: 9,187
|
Have you looked at Parabolic SAR?
|
|
Registered User Joined: 7/13/2008 Posts: 35
|
SG: Yup, but as far as I can tell, it does not use the ATR in it's calculation, so all periods are treated in the same way regardless of volatility.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
hkusp40,
I'm not sure if it is exactly what you want, but you may wish to try the following RealCode Indicator (please keep in mind I am not a programmer):
'# period = UserInput.Single = 14
'# factor = UserInput.Single = 3
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 StartPlot As Integer
If isFirstBar Then
StartPlot = Period*7
TR = Price.High-Price.Low
termRatio = (period-1)/period
ATR = TR
sumweight = termratio+1
weight = 1/sumweight
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
Plot = Single.NaN
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
state = False
extreme = Price.Low
tstop = System.Math.Max(Price.High,extreme+factor*ATR)
End If
Else
If Price.High > tstop
state = True
extreme = Price.High
tstop = System.Math.Min(Price.Low,extreme-factor*ATR)
End If
End If
If CurrentIndex >= StartPlot Then
Plot = tstop
Else
Plot = Single.NaN
End If
If state
extreme = System.Math.Max(extreme,Price.High)
tstop = System.Math.Max(tstop,extreme-factor*ATR)
Else
extreme = System.Math.Min(extreme,Price.Low)
tstop = System.Math.Min(tstop,extreme+factor*ATR)
End If
End If
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 7/13/2008 Posts: 35
|
Bruce L: Absolutely perfect. I modified it slightly to a shape plot (small circle) and added a red Paint Brush condition to color the plot red when price is below it. I've shared it under the layouts tab as "ATR stop mod" should you or anyone else care to take a look.
I'll definately be putting this one to use.
BTW, this indicator behaves as expected in Backscanner as well.
|
|
Registered User Joined: 7/13/2008 Posts: 35
|
I forgot to ask; is the stop and reverse is based on high/low prices or the close?
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
hkusp40,
It's based on high/low prices.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 6/27/2008 Posts: 1
|
Can you e-mail me the code you developed?
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
WPElliott,
The RealCode is posted in my Tuesday, September 30, 2008 12:22:12 PM ET post while the Layout hkusp40 Shared is called ATR stop mod.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Registered User Joined: 2/15/2011 Posts: 35
|
Where do I find the "layouts tab" where the "ATR stop mod" can be found, as referenced in the post below? Thanks!
Charles
QUOTE (hkusp40) Bruce L: Absolutely perfect. I modified it slightly to a shape plot (small circle) and added a red Paint Brush condition to color the plot red when price is below it. I've shared it under the layouts tab as "ATR stop mod" should you or anyone else care to take a look.
I'll definately be putting this one to use.
BTW, this indicator behaves as expected in Backscanner as well.
|
|
Worden Trainer
Joined: 10/7/2004 Posts: 65,138
|
Select Share and choose Browse other users shared items from the menus at the top of StockFinder. You should be able to find the desired Layouts tab there. You will probably want to type:
ATR stop mod
In on the Search line in the window and then select Search so you don't have to scroll through a bunch of layouts which are not of interest.
-Bruce Personal Criteria Formulas TC2000 Support Articles
|
|
Guest-1 |