Duplicate: How Array is filled under different time frame?

Explorer is set to a periodicity of 5 Minutes.

Below is the code for testing

TimeFrameSet(in5Minute);

MA_5MINS = MA(CLOSE, 5);
WMA_5MINS = WMA(CLOSE, 6);

TimeFrameRestore( );

// 10 Minute Time Frame
TimeFrameSet(2 * in5Minute);

MA_10MINS = MA(CLOSE, 5);
WMA_10MINS = MA(CLOSE, 5);

TimeFrameRestore( );

Filter = 1;
AddColumn(BarIndex(), "Bar Index");
AddColumn(MA_5MINS, "MA_5MINS");
AddColumn(WMA_5MINS, "WMA_5MINS");

AddColumn(MA_10MINS, "MA_10MINS");
AddColumn(WMA_10MINS, "WMA_10MINS");

image

The 5 minute time frame appears fine. But the 10 minute time frame data starts filling way down.

image

I was expecting the 10 minute time frame data to be coming in from 9:50 AM.
(Switching periodicity to 10 Mins in Explorer to show what I was expecting).
image

It does that because it is user mistake (either you have not read AmiBroker Users guide at all or have read it too quickly). Please re-read again here (and please take some time reading it slowly from top to bottom). It is all laid out completely there.

You have not expanded after compression. Without expansion you won't get properly aligned data.
Also if you set to 5 minute periodicity then you do not need time frame functions for 5-min variables at all.

// 5 Minute Time Frame (periodicity setting)
MA_5MINS = MA(CLOSE, 5);
WMA_5MINS = WMA(CLOSE, 6);

// 10 Minute Time Frame
// ################ COMPRESSION #############################
TimeFrameSet(tmfrm = 2 * in5Minute);

     MA_10MINS = MA(CLOSE, 5);
     WMA_10MINS = WMA(CLOSE, 5);// WMA needs WMA function, you had set MA

TimeFrameRestore( );

// ################## EXPANSION #############################
MA_10MINS = TimeFrameExpand( MA_10MINS, tmfrm, expandLast);
WMA_10MINS = TimeFrameExpand(WMA_10MINS, tmfrm, expandLast);

// Output
Filter = 1;
AddColumn(BarIndex(), "Bar Index", 1);
AddColumn(MA_5MINS, "MA_5MINS", format = 1.2);
AddColumn(WMA_5MINS, "WMA_5MINS", format );

AddColumn(MA_10MINS, "MA_10MINS", format );
AddColumn(WMA_10MINS, "WMA_10MINS", format );

1 Like

I simply can't understand WHY on earth people do NOT read the manual
https://www.amibroker.com/guide/h_timeframe.html

I am not even talking about reading entire thing. I am just talking about reading ALERT SIGNS placed in orange boxes.

image

The orange boxes in this document literally scream important information that original poster simply ignored. How many times the same thing must be told over and over?

What else can be done to finally make people READ it ???

Reading entire Tutorial http://www.amibroker.com/guide/tutorial.html is ESSENTIAL.

4 Likes

Thanks fxshrat.

I did try TimeFrameExpand. But I simply copied it from the AFL reference and used it directy like so.

TimeFrameExpand(MA_10MINS, 2 * in5Minute );

As there was no syntax error, I missed it. Should have scrolled down and checked the example.

image

It is not enough to skim the docs. You are supposed to read carefully and yes, read the entire thing, not just first sentence. And if you copy formulas you are supposed to copy them fully not just half of it.
If you really read the manual page you have shown here truncated, you will see

http://www.amibroker.com/f?timeframeexpand

weeklyma = TimeFrameExpand( weeklyma, inWeekly ); // expand for display 

See the difference????

You have to ASSIGN the result of TimeFrameExpand. Otherwise it is the same as you called sine function without using the result.

// WRONG
sin( 5 ); // you are ignoring the result of function call !

// CORRECT
result = sin( 5 ); // you are supposed to ASSIGN result of function call to variable

There is no syntax error because it is syntactically correct. But it is logically incorrect. Syntactically, functions may be called without assignment because sometimes it makes sense (if function "does" something like Plot() is drawing a chart as opposed to "returning" something like sin() or TimeFrameExpand(), or if result is used as argument to other function).

1 Like

The thread is a duplicate of dozens of different existing threads:
https://forum.amibroker.com/search?q=timeframeexpand

Always USE SEARCH before posting the same question over and over again.

See: How to use this site