Timeframeset and Timeframeexpand for non Minute boundary

Hello !!

Some questions about Timeframeset and Timeframeexpand are as follows:

If my chart base interval is 15s,
I run the afl program

Buy1 = 0;
Sell1 = 0;
TimeFrameSet(90);
Buy1[LastValue(BarIndex))-2] = 1;
TimeFrameRestore();
b1 = TimeFrameExpand(Buy1, 90);

As far as I understand it, it should be
There are 6 Kbars from lastbar-18 to lastbar-12 of b1, b1 will be set to 1
but I
Plot( b1, "b1", colorRed, styleLine | styleOwnscale);
The picture I saw is
b1 lastbar-19 to lastbar-16 only 4 kbar b1 is set to 1

Excuse me, is this where my understanding is wrong,
Any guidance is welcome

and How to write afl so that when buy1 passes TimeFrameExpand, each signal still has only 1 signal, and it will not become 3~4 signals.

Thanks alotAmibrokerError0003

  • expandPoint - the resulting array gets not empty values only for the last bar within given period (all remaining bars are Null (empty)).

See the TimeFrameExpand( array, interval, mode = expandLast )

@junjun You really need to read, possibly multiple times, the TimeFrame tutorial: http://www.amibroker.com/guide/h_timeframe.html
without skipping parts. Every sentence is extremely important. If you read it slowly, without skipping material making sure that every sentence is understood, you will understand the whole thing and everything will become clear.

Also to get better understanding of what is happening in your code and how functions work, use advice given here: How do I debug my formula?

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.