Metastock - time entries/exits

csen

Newbie
Messages
1
Likes
0
Hi everyone, I recently migrated to Metastock from Tradestation 2000i and am trying to get used to the new syntax. I can figure out the complex examples that I've seen online, but one thing I haven't noticed is how to "hard code" a time entry or exit. I want to write a system that, for example, buys a stock today at the close if it closes down 2 days in a row, and then exits at the close the following day. Once I get that down I'm pretty sure I can go from there. Is this easy? I know in TradeStation you can just do something like this:

If((Close < Close[1]) AND
(Close[1] < Close[2])) Then Buy at Close;

If(BarsSinceEntry = 1) Then ExitLong at Close;

but I haven't been able to figure out the Metastock equivalent. Thanks, guys.

Conor
 
The basic problem with metastock language is that its a bit clunky to attempt to determine if you had an entry etc..

So basically you need to write your entry and then use that same code in the exit and determine the barssince it happened.

csen said:
If((Close < Close[1]) AND
(Close[1] < Close[2])) Then Buy at Close;

becomes something like this in the "Long Entry" signal
buysignal:=((Close < Ref(Close,-1)) AND (Ref(Close,-1) < Ref(Close,-2)));
buysignal;

Your exit "Close Long" would be something like this.
buysignal:=((Close < Ref(Close,-1)) AND (Ref(Close,-1) < Ref(Close,-2)));
BarsSince(buysignal) = 1;


hope it helps.
 
Top