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

Notification

Icon
Error

Options
Go to last post Go to first unread
NewTrader  
#1 Posted : Saturday, November 11, 2006 12:50:40 PM(UTC)
NewTrader

Rank: Member

Groups: Registered, Registered Users
Joined: 11/10/2006(UTC)
Posts: 14

Hi all,

How to code an exit after x number of days; eg exiting 4 days after a moving averages cross over buy signal took place ?

Thanks for the help

Jose  
#2 Posted : Saturday, November 11, 2006 10:54:43 PM(UTC)
Jose

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 1/19/2005(UTC)
Posts: 1,065
Location: Koh Pha-Ngan, Earth

Was thanked: 2 time(s) in 2 post(s)
Due to limitations of this forum's software, I'm unable to post MetaStock code here. I've posted your code solution here. jose '-)
kanellop  
#3 Posted : Sunday, November 12, 2006 3:56:40 PM(UTC)
kanellop

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 6/3/2005(UTC)
Posts: 181

Dear Jose,

Hello.

I want to please you to Post the Metastock Code here.

I didn't find the Code in the Yahoo.com Site!

I gone there but need to Subscribe there etc.!

Kind Regards,

George Kanellopoulos.

wabbit  
#4 Posted : Sunday, November 12, 2006 5:19:28 PM(UTC)
wabbit

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers, Unverified Users
Joined: 10/28/2004(UTC)
Posts: 3,111
Location: Perth, Western Australia

Was thanked: 16 time(s) in 16 post(s)
Jose's solution:

Code:

=============================

Long entry-related timed exit

=============================


{ Long entry-related timed exit



©Copyright 2004~2006 Jose Silva

For personal use only.

http://www.metastocktools.com }



{ User inputs }

exitPds:=Input("Exit trade at x periods",

1,2600,4);

delay:=Input("Entry and Exit delay",0,5,0);



{ Sample entry conditions }

In:=Cross(C,Mov(C,21,E));



{ Entry-related exit latch }

latch:=If(PREV>0,

If(BarsSince(PREV<=0)<exitPds,1,-1),In);



{ Clean Entry & Exit signals }

entry:=latch=1 AND Alert(latch<1,2);

exit:=latch=-1;



{ Plot signals in own window }

0;Ref(entry-exit,-delay)




jose '-)

http://www.metastocktools.com

NewTrader  
#5 Posted : Monday, November 13, 2006 5:49:24 AM(UTC)
NewTrader

Rank: Member

Groups: Registered, Registered Users
Joined: 11/10/2006(UTC)
Posts: 14

Thanks Guys..
mstt  
#6 Posted : Monday, November 13, 2006 5:08:59 PM(UTC)
mstt

Rank: Advanced Member

Groups: Registered, Registered Users, Subscribers
Joined: 7/25/2005(UTC)
Posts: 1,042

Was thanked: 57 time(s) in 54 post(s)

Not forgetting the Inactivity Minimum Change stop in the System Tester or Enhanced System Tester where a coded stop is not necessary.

Roy

MetaStock Tips & Tools

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.