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

 

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

__._,_.___

Posted by: =?UTF-8?Q?Marcin_Jagodzi=C5=84ski?= <marcin.jagodzinski@gmail.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)

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