You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
What about Oct 5, 2009?
What about Oct 5, 2009?
Standard ISO 8601 week (http://en.wikipedia.org/wiki/ISO_8601#Week_dates):
Note that if returns 0, then that week is part of previous year. There are 52-53 weeks in a year, depending on the year... See -> http://en.wikipedia.org/wiki/ISO_8601#Week_dates
In your script Oct 1 and Oct 5 are in the same week.
What are we trying to do here?
I didn't consider that the second day of the month might start the second week.
S - S M T W T F S - S M T W T F S - S M T W T F S - S M T W T F S - S M
Does the 31 day month above have 6 weeks?
Overall, it's a goofy topic, like, what's the point?
May as well argue which time zone gives the REAL 4hr bars
Phy,
If date is 07 Aug 2009 what does it show?
Im trying to get the first trading week of the month
(i need to block trade on friday of the first trading week)
(i need to block trade on friday of the first trading week)
If this effectively means "the first Friday of the month" then a much simpler route would be to check "TimeDayOfWeek(TimeCurrent()) != 5 || TimeDay(TimeCurrent()) > 7"
hmmm...
let me try
if(DayOfWeek() == 5 && Day() <= 7) Print("BLOCK");
Is this correct?
but can it run in tester mode?
if(DayOfWeek == 5 && Day <= 7) Trade == false
Is this correct?
Yes, if that's what you're trying to do...
Unless you want to ignore partial weeks (i.e. only count weeks beginning from the first Monday of the month), then the first Friday of the month must be in the first trading week. And the first Friday of the month has to be the 7th day or earlier of the month.
EDIT: note that there's a difference here between "week" and "trading week" (and you specified the latter above). Using your earlier example, August 7th falls in the first trading week of the month, because August 1st falls on a Saturday when the markets are closed (in most timezones). But, if you're counting something like Sunday-to-Sunday calendar weeks, then August 7th falls in the second week. And, under this definition, there isn't a Friday in the first week of the month for you to block trading on.
but can it run in tester mode?
I haven't tried it, but I can't see any reason why not. The Day() and DayOfWeek() functions return simulated time when backtested, not current real time.