Code for trading day and time
Forums › ProRealTime English forum › ProOrder support › Code for trading day and time
- This topic has 5 replies, 2 voices, and was last updated 2 years ago by robertogozzi.
-
-
08/19/2021 at 2:24 PM #175699
Hello I would like to know how to code to compare two candlestick of too different trading date and with a defined trading time :
exemple
how to compare the opening price of a 5 min candlestick the 2021 08 15 @ 10h30 and the closing price of a 5 min candlestick the 2021 07 15 @ 17h35
I can’t find this in the compagny’s trading book exemples.Many thanks for your help
Regards
08/19/2021 at 3:15 PM #175706There’s no specific instruction, you need to store the current value in a variable, then use FOR…NEXT to scan past candles until you find the desired one:
123456789IF OpenTime = 103000 AND OpenDate = 20210815 THENMyOpen = openFOR i = 1 to BarindexIF OpenDate[i] = 20210715 AND OpenTime[i] = 173500 THENMyClose = close[i]BreakENDIFNEXTENDIFOnly post in the language of the forum that you are posting in. For example English only in the English speaking forums and French only in the French speaking forums.
I moved it from the French forum.
Thank you 🙂
08/19/2021 at 4:28 PM #17571008/21/2021 at 2:32 PM #175843Dear Mr Robertogozzi hello,
Once again thanks for your help
Is it possible to get another help :
I would like to know if it’s possible for the function Opentime and Opendate to use a variable value : to be able in a backtest to optimize
for exemple the best trading time and the best trading day for a trading system
exemple
I want to backtest this system :
I compare the opening price of a 5 minute candle today (it could be a variable as well to test 10 minutes 30 minutes, 1 minute…) @ 10h30
(for exemple but I would like to use a variable data to see if it’s better to compare the previous day @ 10 h30 o r 10h25 or 10h35 …)
with the closing price of a contract the previous trading day @ 18h30 (for exemple but I would like
to use a variable data to see if it’s better to compare the previous day @ 18 h30 o r 18h35 or 18h40 …)
If it’s up, I buy a contrat and then I keep the position for a few hours, and I sell this osition of 1 contract later today @ 16h30
(for exemple but I would like to use a variable data to see if it’s better to keep the position later or sooner @ 16 h35 o r 16h40 or 15h30 or 15h35 …)
I would appreciate if you can help me on this code
Many thanks for your time
Best regards
Pierre
08/21/2021 at 7:03 PM #175866Yes for both OpenTime and OpenDate, but as to OpenDate I can’t think of any situation where optimization could be of much use.
For both of them you can replace numeric constants with a variable name of your choice to be used in optimization.
For OPENTIME you can set a starting time, say 090000, an ending time, say 170000 and a step, say 010000 for 1 hour.
I suggest that you always enter 6 digits and ignore if they are later dropped.
OPENDATE requires 8 digits, instead.
08/23/2021 at 11:20 AM #175983TIMEFRAME does not support variables, so you have to optimize it changing the TF manually.
To compare any candle today with the previous at a given time you have to use a variable, then compare any subsequent candle with it:
123IF Time = 183000 THEN //or OpenTimeTime1830 = closeENDIFThen use Time1830 to be compared to other candles, it will change everyday at 183000 (you can optimize it as explained above).
-
AuthorPosts
Find exclusive trading pro-tools on