Time and Day conditions
Forums › ProRealTime English forum › ProOrder support › Time and Day conditions
- This topic has 8 replies, 2 voices, and was last updated 3 years ago by robertogozzi.
-
-
06/03/2020 at 11:38 AM #134372
Almost every trader loves selecting trading hours and trading days.
The most common way is to use:
123456TimeCond = OpenTime >= HHMMSS and OpenTime <= HHMMSSDayCond = OpenDayOfWeek >= 1 AND OpenDayOfWeek <= 5IF MyConditions AND Not OnMarket AND TimeCond AND DayCond THEN..ENDIFSelecting different days and custom different hours each day is a bit longer, I suggest:
123456789101112ONCE startT = 000000 //Starting TIMEONCE endT = 240000 //Ending TIMEtd0 = 0 AND OpenDayOfWeek = 0 AND OpenTime >= startT AND OpenTime <= endT //Sundaytd1 = 1 AND OpenDayOfWeek = 1 AND OpenTime >= startT AND OpenTime <= endT //Mondaytd2 = 1 AND OpenDayOfWeek = 2 AND OpenTime >= startT AND OpenTime <= endT //Tuesdaytd3 = 1 AND OpenDayOfWeek = 3 AND OpenTime >= startT AND OpenTime <= endT //Wednesdaytd4 = 1 AND OpenDayOfWeek = 4 AND OpenTime >= startT AND OpenTime <= endT //Thursdaytd5 = 1 AND OpenDayOfWeek = 5 AND OpenTime >= startT AND OpenTime <= endT //Fridaytd6 = 0 AND OpenDayOfWeek = 6 AND OpenTime >= startT AND OpenTime <= endT //Saturdaytd7 = 0 AND OpenDayOfWeek > 6 AND OpenTime >= startT AND OpenTime <= endT //unpredictable :)td8 = 0 AND OpenDayOfWeek < 0 AND OpenTime >= startT AND OpenTime <= endT //very unpredictable :) :)tdCond = td0 OR td1 OR td2 OR td3 OR td4 OR td5 OR td6 OR td7 OR td8so you can select DAYS by simply setting 0 or 1 after “=”, as you can select custom hours by changing starting and ending hours, such as starting later on Monday morning or Ending earlier on Friday night or not trading at all on Wednesday.
You may want to use TIME instead of OPENTIME or DAYOFWEEK instead of OPENDAYOFWEEK as best suits your needs.
You can use tdCond to (not) enter a trade:
1234IF MyConditions AND Not OnMarket AND tdCond THEN..ENDIF06/03/2020 at 7:32 PM #134463Link to above added as Log 220 to here …
1 user thanked author for this post.
06/04/2020 at 11:24 AM #13453806/04/2020 at 11:38 AM #134539I let them run 24/7 (I am not a scalper).
Some strategies of mine based on a 4h+ TF may stay open even a 2-3 weeks. On shorter TF’s they normally close quite soon, the same day or within a couple of days at the latest.
Well… tht was a bit off topic. Yes, I always select custom operating time ranges (but once trades are opened I let them run).
1 user thanked author for this post.
06/04/2020 at 12:48 PM #134550robertogozzi, so you have a time frame where you allow entering a trade, say for example between 9.00 – 18.00. Rest of the time is not allowed. But when in a trade you allow it to run 24/7…did I understand you correct?
If so, is the time frame because of potential difference in spreads or different market behaviours? Or maby both?Thanks again for all nice codes and support!
06/04/2020 at 1:11 PM #134553I mainly trade DAX, so spread is higher (even 6 or more pips) and Volatility is lower after 22 (but I usually stop trading at 18/19) till 9 the next morning.
1 user thanked author for this post.
07/24/2021 at 5:49 AM #174074Hi Roberto,
What is the most accurate and effective code of referencing the:
- 8am bar of the current day AND;
- The 16:15pm bar of the previous day AND;
- The 8am bar of the previous day
Irrespective of weekends (i.e. if Tuesday it references Tuesday and Monday and if Monday it references Monday and Friday)
07/24/2021 at 8:29 AM #174076There’s no way to access those bars with direct instructions, you need to save those BarIndex’s in variables as they show.
Each new day each bar becomes yesterday’s bar:
12345678910111213If IntraDayBarIndex = 0 ThenYesterday8 = Today8Today8 = 0Yesterday1615 = Today1615Today1615 = 0EndifIf OpenTime = 080000 ThenToday8 = BarIndexEndif//If OpenTime = 161500 ThenToday1615 = BarIndexEndif07/24/2021 at 8:39 AM #174077To make it work only Mon to Fri:
123456789101112131415If OpenDayOfWeek >= 1 and OpenDayOfWeek <= 5 ThenIf IntraDayBarIndex = 0 ThenYesterday8 = Today8Today8 = 0Yesterday1615 = Today1615Today1615 = 0EndifIf OpenTime = 080000 ThenToday8 = BarIndexEndif//If OpenTime = 161500 ThenToday1615 = BarIndexEndifEndif -
AuthorPosts
Find exclusive trading pro-tools on