Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 2/14/2012(UTC) Posts: 20
|
Hi,
I am trying to formulate the following system in MetaStock: 1. Go Long when the 10 day SMA crosses over the 20 day SMA
2. Exit Long and Go Short when the 20 day SMA crosses over the 10 day SMA
3. When going Long put a stop loss of 3 times the 5 day ATR
I have the following: Buy Order: cross(mov(c,10,s),mov(c,20,s)) Sell Order: cross(mov(c,20,s),mov(c,10,s))
But how can the stop loss ATR be added into this to exit the Long position?
Thanks,
Niall
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/29/2004(UTC) Posts: 1,394 Location: Glastonbury, CT
Was thanked: 2 time(s) in 2 post(s)
|
Where would you like the ATR added to A Low? a MA? MA1:=Mov(C,10,S); MA2:=Mov(C,20,S); Stop:=If(MA1>MA2,(MA1+MA2)/2-(ATR(5)*3),(MA1+MA2)/2+(ATR(5)*3)); Buy:=MA1>MA2 AND C>Stop; Sell:=MA2>MA1 AND C<Stop; Buy-Sell;
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 2/14/2012(UTC) Posts: 20
|
Hi Henry,
Thanks for your email,
Putting the stop in the "Buy Order" screen is just there for the time span of the buy?
What Im trying to do is to: 1. go Long when the 10 day SMA crosses over the 20 day SMA 2. Exit the Long when the 20 day crosses over the 10 day SMA. 3. When a Long is entered into the trade, put a fixed Stop loss that is equal to the price entered into the trade (the close) less 3 times the 5 day ATR
Fixed stop: * Lets say the 10 day SMA crosses over the 20 SMA at 1000. * The 5 day SMA is 20. * In 2 days the lowest of the days trade was 1020 and the Long exited.
Thanks for all and any information,
Niall
|
|
|
|
Rank: Advanced Member
Groups: Registered, Registered Users, Subscribers Joined: 10/29/2004(UTC) Posts: 1,394 Location: Glastonbury, CT
Was thanked: 2 time(s) in 2 post(s)
|
Try using ValueWhen() function to help create the Stop
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 2/14/2012(UTC) Posts: 20
|
|
|
|
|
Rank: Member
Groups: Registered, Registered Users, Subscribers Joined: 2/14/2012(UTC) Posts: 20
|
Hi,
I have the following Buy Order and Sell Order screens but the the stop doesn't seem to be picked up at all:
Buy Order: cross(Mov(C,10,S), Mov(C,20,S))
{go Long when the 10 day SMA of the close crosses over the 20 day SMA of the close}
Sell Order: L < (ValueWhen(1,cross(Mov(C,10,S), Mov(C,20,S)),atr(5)) *3)
{stop the Long when the lowest of the day is less than {the 5 day ATR when it was the 1st last value when the 10 day SMA of the close crosses over the 20 day SMA of the close, and multiply the 5 day ATR by 3}}
but it doesnt seem to be existing the Long?
Any help would be really appreciated,
Thanks
|
|
|
|
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)
|
Personally, I'd be using Richard Dale's excellent (and free) AdvancedStops add-in : http://www.tradernexus.com/advancedstop/advancedstop.htmlnter when} Cross(fastMA, slowMA);
[/code] Code:{Sell}
fastMA:=Mov(C, 10, S);
slowMA:=Mov(C, 20, S);
LE:=cross(fastMA, slowMA);
LX:=slowMA>fastMA;
SL:=HIGH - 3*ATR(5);
Stop:=ExtFml("AdvancedStop.StopLong", LE, SL, 0, SL, 0, 0, 0, 0);
{exit when}
LX or L<Stop;
Untested. wabbit [:D]
|
|
|
|
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.