[R-SIG-Finance] quantstrat - trailingStop offsets?

Brian G. Peterson brian at braverock.com
Mon Oct 13 16:52:05 CEST 2014


On 10/13/2014 09:29 AM, Mark Knecht wrote:
> Good morning,
>     Base question: Are there any quantstrat examples showing how to set
> a minimum profit target before a trailing stop kicks in?
>
>     For example, for a risk stop of 5% and a trailing stop of 3%, I
> don't want to the trailing stop to be executed until I have met a
> minimum profit of at least 2% resulting in a maximum approximate loss
> of 1% if the trailing stop executes.

If your risk stop is 5% and your trailing stop is 3%, there's no reason 
not to just enter the trailing stop at 3%, thus limiting your loss to 3% 
or less.  The risk stop would never be triggered.

Or am I missing what you're asking to do?

There are a number of ways to trigger orders in quantstrat.

Simple signals trigger a rule.  This is how your entry most likely works.

'chain' rule orders are triggered by a fill.  for example, your entry 
order is filled, and the chain rule for that entry will trigger. You can 
see examples of this in the luxor scripts where stop loss and take 
profit orders are entered after a position is initiated.

order sets create an OCO relationship between related orders.  in the 
example above, your stop and profit taking order would be an orderset. 
if one is filled, the other is canceled.

in the case of 'I only want to enter an order if my existing position 
has moved x% in my favor', I guess I'd ask 'why?' and 'how do you plan 
to do this in production?'.  I see very little difference in your 
example between 'enter my trailing stop at -3% after I've gone up 2%, 
but until then, use a 5% stop' and the much simpler 'enter a trailing 
stop at 3% when I get my entry fill'.

All that said, you could do what I think you say you want by triggering 
a signal for 2% above your entry signal.  The rule for that signal would 
cancel the 5% risk stop and add the 3% trailing stop.

Regards,

Brian

-- 
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock



More information about the R-SIG-Finance mailing list