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)