logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
johnnic  
#1 Posted : Tuesday, December 26, 2006 9:04:48 PM(UTC)
johnnic

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 11/20/2006(UTC)
Posts: 21

This is a very simple question but I have had no success in working it out for myself, despite weeks of effort.

How do you code a simple volatility based exit, such as Original buy price - 3*ATR(10) or Original buy price + 5*ATR(10)? My problem is in having Metastock remember the original buy price in order to apply the formula.

I'm sure it's very easy but I can't work it out for the life of me. Please help.

John

vaughn  
#2 Posted : Wednesday, December 27, 2006 2:46:28 PM(UTC)
vaughn

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 3/16/2005(UTC)
Posts: 93
Location: Maryland,US

I am not sure if you were wanting to know how to actually code something like this or if you just want the functionality. I can't help you on the coding part, but I believe there is something available that sounds like what you want. Check this link. I use it as a stop for both long and shorts.
I tried attaching a pic, but it doesn't look like it made it...
johnnic  
#3 Posted : Wednesday, December 27, 2006 4:08:54 PM(UTC)
johnnic

Rank: Member

Groups: Registered, Registered Users, Subscribers
Joined: 11/20/2006(UTC)
Posts: 21

Thanks Vaughn, that's very useful. John

SirShaveKWSN  
#4 Posted : Thursday, December 28, 2006 7:57:09 AM(UTC)
SirShaveKWSN

Rank: Member

Groups: Registered, Registered Users
Joined: 9/22/2006(UTC)
Posts: 14

John:

An interesting problem. Here is one way I have found of setting the initial stop loss, illustrated by some code taken from another post (# 22224) discussing the RMO system:

{variable a7 is the initial stop loss set at "a couple of ticks" below the low of the bar preceding the entry signal}

a5:=(Fml("Rahul Mohindar Osc (RMO)") > 0) AND

(Fml("SwingTrd 2")>0) AND

(Fml("SwingTrd 2")>Fml("SwingTrd 3"));

a6:=a5=1 AND Ref(a5,-1)=0;

a7:=ValueWhen(1,a6,Ref(LOW,-1)-0.25);

Variable a5 is the "long position" indicator for this variation of the RMO system - a5 is "true", or a long position is recommended, when all three RMO indicators are bullish.

Variable a6 is our signal for entry - it is only "true" on bars where all the conditions for a long position are true, but were not true on the previous bar.

Lastly, variable a7 is the initial stop itself - calculated as the "low less a couple of ticks" for the bar immediately preceding the most recent entry signal.

This method is a bit clumsy, and please note that the "initial" stop loss will be reset every time a new "buy signal" is generated. But the idea of refering back to your most recent entry signal as a fixed point for calculating stops (or profit targets) is one way to deal with the problem you mention.

I got this idea from examining the code for the MS PF Fractal Trading Systems, and how they use a "State=1" variable for showing that the system is in a trade. Thus the initial stop losses and profit targets could be based on the most recent point at which the system switched from having no position ("State=0") to having a position ("State=1").

Shave

weird  
#5 Posted : Friday, December 29, 2006 12:39:28 AM(UTC)
weird

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 8/3/2005(UTC)
Posts: 40

Roy Larson, has covered efficient coding of trailing stops in early editions of MSTT, which can be found, at,

www.metastocktips.co.nz

I have cancelled all my other subscriptions this year, including TASC, and this is the only one I will be continuing ;)



Users browsing this topic
Guest (Hidden)
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.