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
Close at end of the week [SOLVED]
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
Re: Close at end of the week
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.
Re: Close at end of the week
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
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
- TJ
- Posts: 7745
- Joined: 29 Aug 2006
- Location: Global Citizen
- Has thanked: 1033 times
- Been thanked: 2224 times
- 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
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.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.
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;