exact calculation of trailing stops

Questions about MultiCharts and user contributed studies.
User avatar
fbertram
Posts: 166
Joined: 16 Oct 2014
Location: Seattle, USA
Has thanked: 36 times
Been thanked: 73 times
Contact:

exact calculation of trailing stops

Postby fbertram » 08 May 2015

Dear MultiCharts fans,

I'd like to better understand how exactly MultiCharts calculates the fill price for a stop-loss during backtesting.

My current understanding is as follows:
* MultiCharts will assume OHLC, when open is closer to high and OLHC when open is closer to low
* a trailing stop should be re-adjusted according to the maximum value the stock has had

I am using the following statement to set up my trailing stop:

Code: Select all

SetStopShare;
SetDollarTrailing(HighD(0) * trailingStop); // trailingStop = 0.005
I am looking at a 5-min bar of MYL on 04/16/2015 @ 12:35:
OHLC = 67.19, 68.47, 67.18, 67.32

Findings:
* As the open is closer to the low, the assumed sequence should be OLHC.
* I have a BUY-STP order, which triggers at 67.55 - which should be executed on the low-to-high leg.
* As the high is 68.47, the trailing stop should be re-adjusted to 68.47 * 0.995 = 68.12
* As the close is much lower than that, I would expect the trailing stop to kick in at 68.12 in the same bar
* however, the trailing stop kicks in the next bar, at a 67-ish price


What am I missing?


Thank you,
best regards, Felix

Image
Attachments
stop-loss.png
stop-loss.png (761.18 KiB) Viewed 434 times

User avatar
Henry MultiСharts
Posts: 9066
Joined: 25 Aug 2011
Has thanked: 1256 times
Been thanked: 2911 times

Re: exact calculation of trailing stops

Postby Henry MultiСharts » 11 May 2015

Hello Felix,

Backtesting works differently based on your settings. Please study this article to understand how the calculation and order fill are being done: How Signals are Calculated
Please also output the price values your code is operating with: Why an Order Was or Was Not Executed.


Return to “MultiCharts”