Re: [amibroker] Re: 4 weeks candles/backtesting

 

I do not know how AB builds the weekly candles.

I always thought they were a Monday to Friday interval.
I really never looked into it because I never needed or used weekly charts.

I believe Tomasz wrote about that on this email group or it was on a AB version upgrade.

Anyway, if they do not start on Monday, I would create my own bars the same way we do with RENKO bars.
There are some Renko codes out there.
I can send you one if necessary.

So, on a Daily timeframe chart, it is possible to properly fill the weekly arrays starting every Monday and finishing on Friday (or, on a better code language: starting every time dayofweek() is minor or equal than its last value).



2016-03-28 13:04 GMT-03:00 Marcin Jagodziński marcin.jagodzinski@gmail.com [amibroker] <amibroker@yahoogroups.com>:
 

Thankt, but unfortunately it's not what I'm looking for... I'd like to have 4 weeks candles starting Monday and ending Friday (4 weeks later).

On Mon, Mar 28, 2016 at 5:40 PM, portfoliobuilder99@gmail.com [amibroker] <amibroker@yahoogroups.com> wrote:
 
[Attachment(s) from portfoliobuilder99@gmail.com [amibroker] included below]

In your code you can identify the first trading day of every 4th week with the afl below.  See screen capture for how it is working.

It may not be what you where asking?


////////////////////////////////////////////////////
// Designed for a rotation system 
// First trading day of every 4th week identifier
////////////////////////////////////////////////////

function firstdayofweek() {
        global dow;
        dow = DayOfWeek();
        SOW = dow < Ref( dow, -1 );
        return SOW;
}

flag = Nz(firstdayofweek());

countflag=Cum(flag); // count firstdayofweek

// rotate only on firstdayofweek, every 2nd one

rotation=flag AND (countflag%4==0); //using the modulus we find days with remainder zero

// to explore the results
Filter = 1;// 

AddColumn( C, "Price", 1.2, -1, -1 ); 
AddColumn(flag, "flag");
AddColumn( dow, "Weekday", 1, colorGrey50, IIf( flag, colorLime, colorDefault) );
AddColumn( rotation,"Rotation Day",1,colorBlue, IIf(rotation, colorYellow,colorDefault));




--
Marcin Jagodziński




--
Agradeço antecipadamente,

----------------------------------------------------------
João Flávio Machado Derzi
+55 (31) 9731-4469

__._,_.___

Posted by: =?UTF-8?Q?Jo=C3=A3o_Fl=C3=A1vio_Machado_Derzi?= <joaoderzi@gmail.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (5)

Check out the automatic photo album with 2 photo(s) from this topic.
first day every 4th week.PNG rolling 4 week bar.PNG

**** IMPORTANT PLEASE READ ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

TO GET TECHNICAL SUPPORT send an e-mail directly to
SUPPORT {at} amibroker.com

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/


.

__,_._,___


EmoticonEmoticon