[R-SIG-Finance] quantstrat - trailingStop offsets?
Mark Knecht
markknecht at gmail.com
Mon Oct 13 16:44:07 CEST 2014
On Mon, Oct 13, 2014 at 7:29 AM, Mark Knecht <markknecht at gmail.com> 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.
>
> I don't see anything in addOrder to do that but I suspect there's
> someway to handle it.
>
> Thanks,
> Mark
I think this is possibly intended to be done in the order sizing
function by setting the size to zero until the minimum gain is met.
<SNIP>
orderqty <- osFUN(strategy = strategy, data = mktdata,
timestamp = timestamp, orderqty = orderqty,
ordertype = ordertype,
orderside = orderside, portfolio = portfolio,
symbol = symbol, ... = ..., ruletype = ruletype,
orderprice = as.numeric(orderprice))
}
if (!is.null(orderqty) && orderqty != 0 && length(orderprice)) {
addOrder(portfolio = portfolio, symbol = symbol,
timestamp = timestamp, qty = orderqty, price =
as.numeric(orderprice),
ordertype = ordertype, side = orderside, orderset = orderset,
threshold = threshold, status = "open", replace = replace,
delay = delay, tmult = tmult, ... = ..., prefer = prefer,
TxnFees = TxnFees, label = label, time.in.force = time.in.force)
}
<SNIP>
If there's a more canned way to do it I'd appreciate understanding it
but for now I'll proceed in that direction.
Sorry for the noise,
Mark
More information about the R-SIG-Finance
mailing list