Reentry after stop loss
Author: safwanvic
Creation Date: 8/18/2011 10:43 AM
profile picture

safwanvic

#1
Hi anyone

Is there a way to do a reentry strategy after a stop loss order?

As an example, the fundamental rules are to buy when P/B ratio < 1, sell when P/B >= 1 or stop loss @ 15%.

Say a stop order has been executed.
Is it possible to reenter the trade (assuming P/B < 1 throughout this particular year), if the last closing price is lower by X% compared to the stop sold price after N bars since the stop was executed?

Many thanks!
profile picture

Cone

#2
What's the difference between a reentry after a stop loss and a "normal" entry?
profile picture

safwanvic

#3
Hi Cone, maybe I can illustrate it this way?

Yr 1: 01/05/2007-30/04/2008: P/B = 1.3
Yr 2: 01/05/2008-30/04/2009: P/B = 0.9
Yr 3: 01/05/2009-30/04/2010: P/B = 1.1
Yr 4: 01/05/2010-30/04/2011: P/B = 1.3

The ratio is the same throughout the year.
So for yr 1, no trade. For yr 2, as P/B < 1 @ 01/05/2008, buy @ market open 02/05/2008.

But say on 31/10/2008, the stop loss order (15% from 1st post) was executed @ price $20.

But I want to reenter the trade after the stop loss, if the last closing price is lower than 50% compared to the $20 stop sold price, after 20 bars since the stop was executed.

e.g. After at least 20 trading days since stop (28/11/2008), the closing price was $8 (< 50% x $20) so buy @ open 01/12/2008, and hold till 01/05/2009 where it's sold @ 02/05/2009 as P/B > 1.

If on 28/11/2008 the closing price is not less than 50%, then the reentry takes place later when the condition is met but
at least after 20 bars.

Hope that's okay? Thanks again.

(The fundamentals are from the additional ascii fields)

Note: In the 1st post, I wanted to say 'lower than' not 'lower by'. Tq.
profile picture

Cone

#4
The last Position that you entered/exited is LastPosition. LastPosition has all the properties of a Position object (because it is one) - properties like ExitSignal, ExitBar, and ExitPrice

So, I'll assume you can exit at a profit target and you trade only 1 position at a time. Further, let's say you used "StopLoss" as your ExitSignal. In your entry logic, you could do something like this:

CODE:
Please log in to see this code.
profile picture

safwanvic

#5
Thanks Cone. I've tried the code but there are error messages come up regarding 'ReentryReset', e.g:
QUOTE:
error CS0201 @ (42,7): Only assignment, call, increment, decrement, and new object expressions can be used as a statement
error CS0103 @ (42,7): The name 'ReentryReset' does not exist in the current context

Also, the "if (Date[bar].Month == 5 && Date[bar - 1].Month != 5)" is because it's May right?
But how do I go about the dataset which include many companies that have different fundamental 'beginning' dates?
profile picture

Eugene

#6
Just dropped by to tell that whenever you see a compiler error (starting with CSxxxx), Bing/Google the CSxxxx and it'll come up with a MSDN reference explaining the message. Like this:

Compiler Error CS0201

You haven't defined the variable ReentryReset before using it.

Compiler Error CS0103

Change to ReentryReset = true;
profile picture

safwanvic

#7
I see, thanks for the info Eugene. It's compiled now.
Still need help for companies with different months though.. Tq.