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

Notification

Icon
Error

Options
Go to last post Go to first unread
roryh  
#1 Posted : Tuesday, November 24, 2009 8:04:49 AM(UTC)
roryh

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/24/2009(UTC)
Posts: 5

I need my system to keep my long signal for 4 bars, before allowing an exit..My 401k k has a minimum holding period of 1 month, so my system on my weekly charts need to stay long at least that long.. How do i code that? Thanks for the help..I'm a bit of a programming caveman!
Justin  
#2 Posted : Tuesday, November 24, 2009 8:18:46 AM(UTC)
Justin

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 9/13/2004(UTC)
Posts: 673
Location: Salt Lake City, UT

There are a couple ways you can do this. You could use the Simulation.CurrentPositionAge function as part of your sell signal (this function only works in the System Tester), such as:

Simulation.CurrentPositionAge >= 4 AND {Sell Signal}

You could also use an Inactivity Minimum Change Stop in the Stops tab (also only in the System Tester). Set a value that will likely never be met, i.e. 100%, and set the periods to 4. This would mean that unless the security price doubled in those 4 bars, it would exit the trade.
roryh  
#3 Posted : Tuesday, November 24, 2009 8:36:12 AM(UTC)
roryh

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/24/2009(UTC)
Posts: 5

Thanks for the quick response Justin. My version of metastock is 7.2, so i don't believe that simulation solution is available to me. The problem with the stop, is that i need the system to stay long at least 4 bars but not close the trade, unless the system itself exits. Do you have another suggestion that might work for me? thanks very much.

rory

Justin  
#4 Posted : Tuesday, November 24, 2009 8:54:10 AM(UTC)
Justin

Rank: Advanced Member

Groups: Registered, Registered Users, Unverified Users
Joined: 9/13/2004(UTC)
Posts: 673
Location: Salt Lake City, UT

You could possibly do something like this:

{Buy Order}
BC:={Buy Condition};
SC:={Sell Condition};
TRADE:=If(PREV<=0,If(BC,1,0),If(SC AND BarsSince(PREV<=0)>=3,-1,PREV))
Cross(TRADE,1)

{Sell Order}
BC:={Buy Condition};
SC:={Sell Condition};
TRADE:=If(PREV<=0,If(BC,1,0),If(SC AND BarsSince(PREV<=0)>=3,-1,PREV))
TRADE=-1

Edit: Sorry there were some initial accuracy issues so make sure to use the latest revision of these.
roryh  
#5 Posted : Tuesday, November 24, 2009 11:34:28 AM(UTC)
roryh

Rank: Newbie

Groups: Registered, Registered Users
Joined: 11/24/2009(UTC)
Posts: 5

hey it works great..thanks Justin!!
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.