Close at end of the week  [SOLVED]

Questions about MultiCharts and user contributed studies.
bryan1618
Posts: 12
Joined: 01 Nov 2016
Has thanked: 7 times

Close at end of the week

Postby bryan1618 » 18 May 2017

Hi All,

I want my trade to automatically close at the end of the week. I know there is a study for the end of the day close but what can I use for the end of the week. For example close at the New York Close on Friday.

Thank you in advance.

Bryan

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Close at end of the week

Postby TJ » 18 May 2017

Hi All,

I want my trade to automatically close at the end of the week. I know there is a study for the end of the day close but what can I use for the end of the week. For example close at the New York Close on Friday.

Thank you in advance.

Bryan

You will need to find ways to account for non-trading Fridays (ie holidays),
or half-day Fridays.

bryan1618
Posts: 12
Joined: 01 Nov 2016
Has thanked: 7 times

Re: Close at end of the week

Postby bryan1618 » 18 May 2017

TJ,

Thank you TJ, I'll have to figure out how to account for that. Having that capability will be a luxury for my strategy but it will not make it or break it.

Thanks,

Bryan

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Close at end of the week

Postby TJ » 18 May 2017

What is your chart resolution?

bryan1618
Posts: 12
Joined: 01 Nov 2016
Has thanked: 7 times

Re: Close at end of the week

Postby bryan1618 » 18 May 2017

What is your chart resolution?
1 Tick chart

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Close at end of the week

Postby JoshM » 19 May 2017

I want my trade to automatically close at the end of the week. I know there is a study for the end of the day close but what can I use for the end of the week. For example close at the New York Close on Friday.
With the `DayOfWeek()` keyword you can check for the day of week, and then for instance use the `Time_s` keyword to specify the time at which the position should be closed.

Untested, but something like this I think:

Code: Select all

// On Fridays..
if (DayOfWeek(Date) = Friday) then begin

// .. starting at 16:00 o'clock
if (Time_s > 1600) and (Time_s[1] <= 1600) then begin

// Generate the exit long and exit short orders here.

// Also invalidate the enter long and enter short conditions
// here (so that no new market position is opened after 16:00
// on Friday

end;

end;

bryan1618
Posts: 12
Joined: 01 Nov 2016
Has thanked: 7 times

Re: Close at end of the week  [SOLVED]

Postby bryan1618 » 05 Jun 2017

Thank you JoshM!


Return to “MultiCharts”