How to script a trailing stop when using a 1 week data timeframe?

I used the following code thinking this would calculate a trailing stop of the daily high when using a 1 week timeframe, where it buys based on using 2 moving average.

Close(Day(PERIODAMOUNT=1)) <= STOP(STOPTYPE=Percent, TRAILING=True, STOPVALUE=5.00, CALC=High)
. Unfortunately, I am unable to reconcile how OPTUMA came up with the last sell at 63.23 for example. I used a script of high * 0.95 to track the 5% trailing stop levels after the buy and I expected that when price went below the maximum level the stop would have been triggered. I have attached a screen shot of the chart with comments that should better explain the problem, namely I cannot reconcile how the final sell at 63.63 since it does match any of the high * 0.95 calculations.

QLD-Back-test-weekly-time-frame-using-a-daily-trailing-stop-2023-10-18.pdf (102 KB)

I will add that the stop price appears to correspond to the opening price on September 18, but I still can’t reconcile how that was the calculated sell price based on the script.

Hi Donald,

When using weekly timeframes you can’t reference daily data as only the Monday open, Friday close, and intraweek high/low prices are available, not the daily values. You can only go up in timeframe (ie reference weekly in daily tests, monthly in weekly, etc) as they can be calculated from the lower timeframe bars.