unknown specific day in the month
Forums › ProRealTime English forum › ProOrder support › unknown specific day in the month
- This topic has 11 replies, 4 voices, and was last updated 9 months ago by PeterSt.
-
-
02/13/2024 at 4:34 PM #228076
Hi everybody,
after the big short candle of today due to the CPI data, I’d like to add in my strategies some lines to avoid any new trade in the period around the news.
For Jobless data it’s easy because the news is always on Thursday all weeks.
But for other news (Payrolls or CPI or RetailSales) that are, for example, only on the 2nd Tuesday of the month what do I have to write?
Which are the instructions to let it know to avoid ONLY the second Tuesday ?
Many thanks for your help
02/13/2024 at 4:55 PM #228080Hi MaoRai,
You could make some sort of loop which traces backwards (to) the 1st day of the month (Month <> Month[1]) and then looks forward for the 2nd Tuesday, starting 1 day further than what you found tracing backwards.
More easy could be to just hard code the dates (see below for a list already there – you can extend it yourself of course).Regards,
Peter1 user thanked author for this post.
02/13/2024 at 5:00 PM #22808202/13/2024 at 5:09 PM #228084Here you go : https://www.bls.gov/schedule/news_release/cpi.htm
1 user thanked author for this post.
02/13/2024 at 5:32 PM #22809202/13/2024 at 6:20 PM #228096I shall be honest … I have been trying for 45 minutes or so, and couldn’t do it in that time.
Then I saw your post, Iván, tried that, but unfortunately that doesn’t do a job either. Now 15 minutes later with your code as a base, I am going to give up and have a beer instead. 😜To let it work, (please) show a fully working snippet and point (Graph) at the 2nd Tuesdays of the month. Do you need a TimeFrame command, then inject that too.
A strange beast this is !
02/13/2024 at 6:31 PM #228097Hi Ivan,
thanks for your code but I don’t think it’s my request.
I need a code that:
- if the dayofweek=2 and (it is the second Tuesday of the month) and (hour=>14 and hour<=15) THENNoTrade=1
Else
NoTrade=0
ENDIF
- // where notrade=1 means not opening any trade in that day and hours
02/13/2024 at 7:31 PM #22810602/13/2024 at 8:08 PM #228109Sorry, for the hourly part I looked at it as not trading for one hour between 14h and 15h, but it seems you actually meant for 2 hours, not one. Although depending if you used hour in its PRT meaning of candle closing time, or as a word, I am not sure if you meant no trade between 13h and 15h, or between 14h and 16h.
If from 13h to 15h, please replace “and openhour=14 then” in line 1 by “and (openhour=13 or openhour=14) then“
If from 14h to 16h, please replace “and openhour=14 then” in line 1 by “and (openhour=14 or openhour=15) then“
1 user thanked author for this post.
02/14/2024 at 4:51 AM #228118Hi JC – I am sure this is perfect. Very well done. No trading in the hour of PCI data (which comes in at 15:30).
For MaoRai : don’t forget about the Daylight Savings difference between Europe (the area you imply) and the USA (which designates the PCI report at 08:30).02/14/2024 at 5:01 AM #228121Just in case, about the Daylight Saving :
12345678910111213141516DLS = 0 // 0 = Normal. 1 = Autumn. 2 = Spring.If Date >= 20221031 and Date <= 20221104 thenDLS = 1 // Autumn. USA is one hour early.elsif Date >= 20230312 and Date <= 20230326 thenDLS = 2 // Spring. USA is one hour early.endif// Justadd a group for convenience (no difficult If/Else stuff).// And the above can even be used for more history backtesting.If Date >= 20231029 and Date <= 20231105 thenDLS = 1 // Autumn. USA is one hour early.elsif Date >= 20240310 and Date <= 20240331 thenDLS = 2 // Spring. USA is one hour early.endif02/14/2024 at 8:04 AM #228132No trading in the hour of PCI data (which comes in at 15:30).
No PeterSt … that is 14:30.
- if the dayofweek=2 and (it is the second Tuesday of the month) and (hour=>14 and hour<=15) THENNoTrade=1
-
AuthorPosts
Find exclusive trading pro-tools on