Download software Tutorial videos
Subscription & data-feed pricing Class schedule


New account application Trading resources
Margin rates Stock & option commissions

Attention: Discussion forums are read-only for extended maintenance until further notice.
Welcome Guest, please sign in to participate in a discussion. Search | Active Topics |

ATR stop revisited Rate this Topic:
Previous Topic · Next Topic Watch this topic · Print this topic ·
hkusp40
Posted : Sunday, September 28, 2008 10:29:54 PM
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
StockGuy
Posted : Tuesday, September 30, 2008 8:07:18 AM

Administration

Joined: 9/30/2004
Posts: 9,187
Have you looked at Parabolic SAR?
hkusp40
Posted : Tuesday, September 30, 2008 8:44:48 AM
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.
Bruce_L
Posted : Tuesday, September 30, 2008 12:22:12 PM


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
hkusp40
Posted : Thursday, October 2, 2008 3:18:27 AM
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.
hkusp40
Posted : Thursday, October 2, 2008 3:43:57 AM
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?
Bruce_L
Posted : Thursday, October 2, 2008 8:01:57 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
hkusp40,
It's based on high/low prices.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
WPElliott
Posted : Thursday, October 2, 2008 10:53:08 AM
Registered User
Joined: 6/27/2008
Posts: 1
Can you e-mail me the code you developed?
Bruce_L
Posted : Thursday, October 2, 2008 10:57:20 AM


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
mass54thcob
Posted : Monday, October 22, 2012 2:02:17 AM
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.

Bruce_L
Posted : Monday, October 22, 2012 9:02:55 AM


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