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

 
[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));

__._,_.___

Attachment(s) from portfoliobuilder99@gmail.com [amibroker] | View attachments on the web

1 of 1 Photo(s)


Posted by: portfoliobuilder99@gmail.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

Check out the automatic photo album with 1 photo(s) from this topic.
first day every 4th week.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