I'm not exactly sure how to ask the question but when telling Amibroker that you want a calculation performed on Today's information, do you use the number 0 or the number 1 to mean today? Since -1 is yesterday I would assume 0 is today but this question has been bugging me.
Thank you
Tom
You don't say which interval you refer to.
But on EOD:
/// EOD example
///
today_condition = Cross(C,MA(C,50));
///
/// @link http://www.amibroker.com/guide/afl/ref.html
yesterday_condition = Ref(today_condition, -1);
///
So there is no number for today.
Today's close price on EOD data is
today_price = Close;
Yesterday's close price on EOD data is
yesterday_close = Ref(Close, -1);
Recommended reading
https://www.amibroker.com/guide/h_understandafl.html
(Also see 3rd table there besides of everything else)
If you refer to intraday data then today's close price is
today_close = TimeFrameGetPrice("C", inDaily, 0);
yesterday's close price on intraday data is
yesterday_close = TimeFrameGetPrice("C", inDaily, -1);
http://www.amibroker.com/guide/afl/timeframegetprice.html
(NOTE: take care of future leaks in backtesting if shift is zero)
1 Like
Tomasz
August 11, 2020, 12:03pm
3
Technically you could use Ref() with zero offset but it is redundant and waste of keystrokes.
thisbar_close = Ref( Close, 0 ); // redundant, don't use
You don't really need to use Ref() at all:
thisbar_close = Close; // just that
1 Like
Thank you, this really helps.
Tom