Timepoint-related condition
Forums › ProRealTime English forum › ProBuilder support › Timepoint-related condition
- This topic has 12 replies, 3 voices, and was last updated 6 years ago by Foickert.
-
-
12/08/2017 at 2:58 PM #55126
Hi traders!
I’m stuck with a kind of complicated timepoint-related condition. I give an example.
If the following condition is true, I want the order to be executed today:
The price of yesterday at 16 o clock was higher than yesterday at 13 o clock
I couldnt find examples of how to connect e.g. the close-variable to a certain timepoint (such as yesterday, 16.00 o clock).
Does anybody know?
Thanks a lot guys!!
12/08/2017 at 8:34 PM #5519012/08/2017 at 8:43 PM #5519412/08/2017 at 8:55 PM #55195First you must be on 1h timeframe or lower to get the times right. Here is the code:
123456789101112once close13=0once close16=0if time=80000 and close13>0 thenif close16>close13 thenbuy 1 contract at marketendifelsif time=130000 thenclose13=closeelsif time=160000 thenclose16=closeendifThis snippet buys at 8:00 1 contract at market if the close yesterday 16:00 was higher than the close yesterday 13:00.
1 user thanked author for this post.
12/08/2017 at 10:26 PM #55207Great! Thanks for the code!
Now there’s just one issue left.
“close13” and “close16” need to be overwritten everyday.
One strategy is set to buy at 14:00 with the condition of “close13” of yesterday and “close16” of yesterday.
As it buys at 14:00, the variable “close13” has already been updated one hour before though with todays value.
For the buy order at 14:00 there would need to be a variable “close13” with the value of yesterday and “close13” with the value of today (this one of today will be used tomorrow then).
I was looking for an option to separate the variables and name them DYNAMICALLY by Date, like close13_Yesterday and close13_Date, but that wasnt possible. Any idea for a different workaround?
12/09/2017 at 3:46 PM #55223A couple more viariables and IntraDayBarIndex will do the trick:
12345678910111213141516once close13 = 0once close13today = 0once close16 = 0once close16today = 0if IntraDayBarIndex = 0 THENclose13 = close13todayclose16 = close16todayendifif time = 140000 AND close16 >close13 thenbuy 1 contract at marketendifif time = 130000 thenclose13today = closeelsif time = 160000 thenclose16today = closeendifRoberto
12/09/2017 at 6:03 PM #55228Thanks for your help, Roberto!
I think there’s a little misunderstanding with my example.
Lets assume the following:
“close13” yesterday was at 100 points.
“close16” yesterday was at 105 points.
Today at 13h “close13today” has been defined at 110 points.
And now its 14h.
From my understanding, your code would now express the following:
if time = 140000 AND 105 > 110 then ..
Because one hour before (at 13h), the variable “close13” has been newly defined as “110” due to the line
“close13 = close13today”
and the definition
if time = 130000 then “close13today = close” ..
, no?
If I’m wrong, then I didnt understand this part yet:
if IntraDayBarIndex = 0 THENclose13 = close13todayclose16 = close16todayendif12/09/2017 at 6:08 PM #55229Line 9 would be:
1if time = 140000 AND 105 > 100 then ..Did you check if it works? You should use GRAPH to debug it and realize what it does.
Lines 5-8 make room for the new day.
1 user thanked author for this post.
12/09/2017 at 8:52 PM #55237Ahhh.. I think I understood the code now. Should work, I think, yes.
I will test and see in real environment when the markets open on monday.
One of my strategies include positions to be held over night. Is there an option to deactivate the standard “sell all positions at 0:00h” setting of ProRealTime?
I dont understand what this is there for?!
12/09/2017 at 11:48 PM #55244Is there an option to deactivate the standard “sell all positions at 0:00h” setting of ProRealTime? I dont understand what this is there for?!
Sorry Foickert, I never heard of that setting. I know about
1DEFPARAM FlatAfter = 180000which close ALL trades at that time.
1 user thanked author for this post.
12/10/2017 at 12:01 AM #55247It seems to be part of the DEFPARAM FLATBEFORE function. I set this parameter in the assisted creation tool and it created the following comment in the code:
// Das Handelssystem wird um 0:00 Uhr alle pending Orders stornieren und alle Positionen schließen. Es werden vor der “FLATBEFORE”-Zeit keine neuen Orderaufträge zugelassen.
DEFPARAM FLATBEFORE = 083900Saying that “the trade system will cancel all pending orders and closes all positions at 0:00 o clock”.
12/10/2017 at 11:32 AM #552591DEFPARAM FLATBEFORE = 083900will cause all trades BEFORE that time (starting from the beginning of the day, that is at 00:00 or whatever time is set for that instrument) to be closed, if active or pending, or not entered.
That’s what it is meant for.
1DEFPARAM FLATAFTER = 180000will do the same but for trades after that time till the end of the day.
12/10/2017 at 6:39 PM #55286Ah ok, now I understand whats the deal with the “00:00 o clock”.
As I have one strategy that is supposed to keep positions active over night, I will not work with “FLATAFTER/FLATBEFORE” for that one.
Thanks again for your help, Roberto. Im excited how it’s all gonna work out on monday 😉
-
AuthorPosts
Find exclusive trading pro-tools on