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 as a trailing stop Topic Rating:
Previous Topic · Next Topic Watch this topic · Print this topic ·
BerkoBob
Posted : Thursday, August 7, 2008 9:36:27 AM
Registered User
Joined: 3/29/2007
Posts: 19

I'd like to use average true range as a trailing stop in backscanner.  Any ideas how I might do this?  Thank you in advance.

Bruce_L
Posted : Thursday, August 14, 2008 8:31:54 PM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
I do not know of a practical automated method of doing so using the current version of Blocks. Once RealCode Trade Based Rules become available it should be possible (I do not know the time frame for when this might happen).

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
BerkoBob
Posted : Friday, August 15, 2008 4:19:36 AM
Registered User
Joined: 3/29/2007
Posts: 19
I was thinking I could create a condition to test if the low is less than the greatest high of the last 50 days minus the ATR * 3.  

if price.close < max high(50) - ATR * 3 then pass

Would that work?

Let's say my stock ABC is trading at $45 and has an ATR of $2 and has a 50 day high of $50.  If I'm right, the condition should pass when ABC reaches $43.  It can happily trade in a range of 3 * ATR i.e. 3 * 2 = 6 from the high of 50.

Any thoughts?
Craig_S
Posted : Friday, August 15, 2008 8:31:13 AM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
I just shared a chart called "Berko Stop" that plots your proposed indicator.  You can use it to generate your conditions for rules in Bakcscanner.  Let me know what you think.

- Craig
Here to Help!
Bruce_L
Posted : Friday, August 15, 2008 8:43:48 AM


Worden Trainer

Joined: 10/7/2004
Posts: 65,138
BerkoBob,
Another option would be to create a RealCode Condition:

'# maxHighPeriod = UserInput.Integer = 50
'# ATRperiod = UserInput.Single = 14
'# factor = UserInput.Single = 3
'#Cumulative
Static TR As Single
Static ATR As Single
Static termRatio As Single
static Weight As Single
Static sumWeight As Single
If isFirstBar Then
    TR = Price.High - Price.Low
    termRatio = (ATRperiod - 1) / ATRperiod
    ATR = TR
    sumweight = termratio + 1
    weight = 1 / sumweight
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
End If
If Price.Low <= Price.MaxHigh(maxHighPeriod) - factor * ATR Then Pass

The problem with either approach is that they will only match an actual ATR based stop when the Trade is exactly 50-Days old since they can be based on Highs from before the Trade or not include all of the Highs in the Trade in their calculation.

-Bruce
Personal Criteria Formulas
TC2000 Support Articles
BerkoBob
Posted : Friday, August 15, 2008 8:51:09 AM
Registered User
Joined: 3/29/2007
Posts: 19
Craig,

That's wonderful, thank you.  All I need now is a way to set HighPeriod to be the date of the trade in BackScanner.  I guess I'm going to have to wait for Realcode trade based stops for that, right? 

Antoine
Craig_S
Posted : Friday, August 15, 2008 9:38:14 AM


Worden Trainer

Joined: 10/1/2004
Posts: 18,819
Correct.

- Craig
Here to Help!
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.