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
@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?