Timepoint-related condition

Forums ProRealTime English forum ProBuilder support Timepoint-related condition

Viewing 13 posts - 1 through 13 (of 13 total)
  • #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!!

     

    #55190

    You simply save the values in a variable so you have them for the next day.

     

    #55194

    Hi Despair!

    thanks a lot for your reply and the hint. 

    Im super new to probuilder and in general to coding trade strategies (actually I started out just today). 

    Could u give me some more info on how to do that?

    #55195

    First you must be on 1h timeframe or lower to get the times right. Here is the code:

    This 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.
    #55207

    Great! 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?

    #55223

    A couple more viariables and IntraDayBarIndex will do the trick:

    Roberto

    #55228

    Thanks 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 THEN
       close13 = close13today
       close16 = close16today
    endif
    #55229

    Line 9 would be:

    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.
    #55237

    Ahhh.. 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?!

     

     

    #55244

    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?!

    Sorry Foickert, I never heard of that setting. I know about

    which close ALL trades at that time.

     

    1 user thanked author for this post.
    #55247

    It 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 = 083900

    Saying that “the trade system will cancel all pending orders and closes all positions at 0:00 o clock”.

    #55259

    will 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.

    will do the same but for trades after that time till the end of the day.

     

     

    #55286

    Ah 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 😉

Viewing 13 posts - 1 through 13 (of 13 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login