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

Notification

Icon
Error

Options
Go to last post Go to first unread
manatrader  
#1 Posted : Tuesday, April 7, 2009 10:51:40 PM(UTC)
manatrader

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/30/2009(UTC)
Posts: 46
Location: Hawaii, US

Hi, back again with another stop related question. I got similar results to my trailing stop problem when including stop info in the buy sell section for strategies, instead of the stop tab. Adding a stop increased the number of trades excessively, but incorrectly made almost all trades profitable. In addition to regular long position exit criteria, I added "or (ValueWhen(1,Simulation.CurrentPositionAge=0,OPEN))-(ValueWhen(1,Simulation.CurrentPositionAge=0,OPEN)*(OPT4))>C"

Opt4 was set for values of .03-.09. I am testing always in the market mean reversion strategies, and trying to refine them with stops (like buying when close is below MA 5 and selling if above). I expect the number of trades to increase with a stop, but it can't be right for 495 out of 497 trades to be winners, with average losses at zero. So, I need to specify the trade price if stopped out, like

if (ValueWhen(1,Simulation.CurrentPositionAge=0,OPEN))-(ValueWhen(1,Simulation.CurrentPositionAge=0,OPEN)*(OPT4))>C, tradeprice=(ValueWhen(1,Simulation.CurrentPositionAge=0,OPEN))-(ValueWhen(1,Simulation.CurrentPositionAge=0,OPEN)*(OPT4))

Sorry, I couldn't find this googling or in the primer. Thanks for any help!!
wabbit  
#2 Posted : Wednesday, April 8, 2009 1:55:05 AM(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)
Something like???

entryPrice:=ValueWhen(1,Simulation.CurrentPositionAge=0,OPEN);
stopPrice:=entryPrice*(1-OPT4);
exitPrice:=ValueWhen(1,Ref(C,-1)<stopPrice, OPEN);
{return}
exitPrice;




wabbit [:D]

manatrader  
#3 Posted : Wednesday, April 8, 2009 5:46:13 PM(UTC)
manatrader

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/30/2009(UTC)
Posts: 46
Location: Hawaii, US

Hey thanks, I got error message not a recognized name constant or operator trying your suggestion, is there a typo?

Also it seemed to me I should make exit price include 'or' statement for when target is hit instead of stop. Correct?

exitPrice:=ValueWhen((1,Ref(C,-1)<stopPrice, OPEN) OR C>MOV(C,5,E))

Thanks!

EDIT - now have an 'end of function expected' message after tidying up (sell rule for long) please help! :)

entryPrice:=ValueWhen(1,Simulation.CurrentPositionAge=0,OPEN);
stopPrice:=entryPrice*(1-OPT4);
exitPrice:=ValueWhen((1,Ref(C,-1)<stopPrice, OPEN) OR C>MOV(C,5,E));
{return}
exitPrice;



wabbit  
#4 Posted : Wednesday, April 8, 2009 6:43:36 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)
entryPrice:=ValueWhen(1,Simulation.CurrentPositionAge=0,OPEN);
stopPrice:=entryPrice*(1-OPT4);
exitPrice:=ValueWhen(1, Ref(C,-1)<stopPrice OR Ref(C>Mov(C,5,E),-1), OPEN);
{return}
exitPrice;



wabbit [:D]

manatrader  
#5 Posted : Thursday, April 9, 2009 12:10:36 AM(UTC)
manatrader

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/30/2009(UTC)
Posts: 46
Location: Hawaii, US

Thanks again, wabbit! Ran the tests again with the same results, I had hoped directly referencing the exit price would give realistic results but.. no. Any ideas?
wabbit  
#6 Posted : Thursday, April 9, 2009 12:15:18 AM(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)
Export the system test and send it to me via email and I will have a look.


wabbit [:D]

manatrader  
#7 Posted : Thursday, April 9, 2009 4:06:10 AM(UTC)
manatrader

Rank: Advanced Member

Groups: Registered, Registered Users
Joined: 3/30/2009(UTC)
Posts: 46
Location: Hawaii, US

Oops oops, I had left the trail stop option set in the tabs, checked again and this new way of placing a stop is working! I did figure out how to save a report tho so I will email one with the errant results from using the stops in the stop tab.

Now, I'd like to work on to making a trail stop within the buy/sell rules.. something like (sell rule for long exit)..

entryPrice:=ValueWhen(1,Simulation.CurrentPositionAge=0,OPEN);
stopPrice:=HHV(OPEN,0) - (entryPrice*OPT4);
exitPrice:=if(ValueWhen(1, Ref(C,-1)<stopPrice,stopPrice) or C>Mov(C,opt2,E), OPEN, c);
{return}
exitPrice;

Don't hurt yourself laughing too hard LOL

EDIT - looks like the max loss stop from the stops tab is the only way to test with daily OHLCV data. Good enough! :)

Users browsing this topic
Guest (Hidden)
Similar Topics
Trailing stop incorrect results (MetaStock)
by manatrader 3/29/2009 7:50:40 PM(UTC)
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.