XShift and Ref() together work perfectly for calculating and displaying indicators that have future values. Look at "Ichimoku clould" code shipped with AmiBroker, or "Displaced Moving Average" also shipped with AmIBroker. It can be created via drag drop (price + DispMA overlay).
Plot( C, "Close", colorDefault, styleCandle );
Displacement = Param("Displacement", 15, -50, 50 );
Periods = Param("Periods", 20, 1, 100 );
m = MA( Close, Periods );
Plot( m, _DEFAULT_NAME(), colorRed, styleLine, 0, 0, Displacement );
Your code can be adopted too easily instead of assuming things without actually trying. You already had all necessary information served by @beppe and @snoopy.pa30 it was just a matter of making some effort and following their advice (actually just reading the Knowledge Base article to the very end: http://www.amibroker.com/kb/2015/01/14/drawing-line-extensions-on-future-bars-using-afl/ - as it has everything explained step-by-step with every possible detail)
If you have put a single second of thought you would just change SINGLE LINE of your code from
Plot(x,"x",colorAqua); // original
Plot(x,"x",colorAqua, styleLine, 0, 0, phase); // after change it plots into the future!
Surpise. It plots into the future.
If you want this sawtooth to start at specified date you need to change 5th line of your code to:
bar = BarsSince(Ref(DateNum()==d, phase));
Again, this Ref() technique is explained in great deal of detail in the KB article quotes. It was just a matter of reading and copy-pasting code from KB.
You can apply (2 * phase) or (3 * phase) shift or whatever multiple as @snoopy.pa30 already suggested earlier.
Remember: Everything in AmiBroker is possible.
PS. This thread shows that excerpts from Knowledge Base only give excuse NOT to read the entire KB article.