Purpose of using '+1' in mode for TimeFrameExpand

In some of the afl (e.g. 3TF Candlestick chart) on Amibroker site, I see the following statements:

TimeFrameSet(15*in1Minute);
.
.
.
TFBarIndex = BarIndex();
TimeFrameRestore();

.
.
.
TFBarIndex = TimeFrameExpand(TFBarIndex, TFSec, expandLast + 1);
NewTFBar = IIf(TFBarIndex != Ref(TFBarIndex, -1), 1, 0);

I understand what expandFirst or expandLast does, but what is the meaning of ‘expandLast + 1’? What purpose is served by ‘+1’ in the mode?

The code you have presented is wrong. You should use just constants like expandLast without adding anything. If you add numbers you are changing the value and the meaning changes and it is no longer expandLast. expandLast is currently equal to 0, so adding 1 gives 1 which is the same value as expandFirst, so the original writer should rather write expandFirst. But again, using hard coded numbers instead of is fundamentally wrong. You should use CONSTANTS.

1 Like

Thanks @Tomasz for clearing the doubt.
I was also not comfortable with the ‘+1’ and thus my post. I checked the chart after changing from ‘expandLast + 1’ to ‘expandFirst’ and it is same. Looks like someone started using the ‘+1’ long back and everyone just continued with it.