Skip to content

stoptrailing mechanics question in MACD example - Quantstrat

2 messages · Joshua Ulrich, Derek Wong

#
On Wed, Feb 17, 2016 at 2:22 AM, Derek Wong <treydog999 at gmail.com> wrote:
For OHLC data, the sell stoplimit order price will be based on the
high price, but the order evaluation is based on the close price.
That means the stoplimit will only be moved if the close is >= order
price + threshold.  And when it is moved, the new order price will be
high - threshold.

For BBO data, a sell stoplimit order price *and* evaluation would be
based on the offer price.

I don't recall at the moment why they're different.  Perhaps someone
else will remember.

  
    
#
Hi Joshua,

Thank you for that reply. I will take a look at that. But what you
explained seems to be the conditions I found by digging into the order
book and order update logic. The confusing part for that was using the
OHLC data and mixing the close price as a "filter" rather than just
highest high lowest low. Also for the fills as well, as a close below
the stop limit order is not really realistic. As you can be filled by
the low of the day and still have the close above (high of the day and
close below for a short), in reality you would have obtained a fill in
the market. This is assuming that the stoptrailing order is in the
market as it executes at the limit price. But in the back test you
would still be maintaining a position as the order would not be
filled. This leads to some disparity in the results as only winners
would not be filled and continue higher but any losers would be cut
off properly. When in reality both would have been closed. I believe
this backtesting behavior biases the returns upwards when using the
stoptrailing order.

Thanks again,

Derek
On Sat, Mar 12, 2016 at 11:26 AM, Joshua Ulrich <josh.m.ulrich at gmail.com> wrote: