Trading two timeslots per day

Forums ProRealTime English forum ProBuilder support Trading two timeslots per day

Viewing 12 posts - 1 through 12 (of 12 total)
  • #200654

    I would like to trade around the time Europe opens  (say 8.30 – 11.00 West-European time) and around the time the US opens (say 15.00 – 16.30 in West European time)

    I can write:
    DEFPARAM FLATBEFORE = 083000
    DEFPARAM FLATAFTER = 110000
    and that works fine for that timeslot.

    But when I double this to
    DEFPARAM FLATBEFORE = 083000
    DEFPARAM FLATAFTER = 110000
    DEFPARAM FLATBEFORE = 150000
    DEFPARAM FLATAFTER = 163000
    things go wrong.

    How to write two timeslots per day? Thanks!

    #200658
    JS

    Hi @Vogeltje

    You can try this…

    1 user thanked author for this post.
    #200673

    So it means also, that if you are not in any of the time slot, you have to force exit orders (and not put any new pending ones), like the FLATBEFORE and FLATAFTER are used for.

    2 users thanked author for this post.
    #200792

    Thanks JS and Nicolas.
    I have added a condition and written as the code:

    //two timeslots

    TimeSlot1 = 0

    TimeSlot2 = 0

    If OpenTime >= 083000 and OpenTime <= 110000 then

    TimeSlot1 = 1

    ElsIf OpenTime >= 150000 and OpenTime <= 163000 then

    TimeSlot2 = 1

    EndIf

    //Condition timeslots

    c1= TimeSlot1 = 1 OR TimeSlot2 = 1

    Working with this condition works just fine.

    By the way, I tried skipping:

    TimeSlot1 = 0

    TimeSlot2 = 0

    but then it is not working. I do not really understand why TimeSlot1 = 0 is necessary. I think Prorealcode does not need to declare a variable. So, why is it not enough to declare

    If OpenTime >= 083000 and OpenTime <= 110000 then

    TimeSlot1 = 1 ?

    I see a lot of examples where a variable is first declared 0,  so this is not clear to me….

    #200803
    JS

    If you do not set the variable (TimeSlot) to zero (0) at the beginning of your code, then once True (1), it will always remain True (1).

    When the “TimeSlot” meets the correct times, it is set to 1 (True) and if not, it is reset (at the beginning of the code) to 0 (False)

    1 = True

    0 = False

    So, you could also write your condition like this:

    C1 = TimeSlot1 or TimeSlot2

    1 user thanked author for this post.
    #200805

    A ha great JS, that is really helpful. I think now I can use this kind of setup myself more often!

    1 user thanked author for this post.
    avatar JS
    #202907

    Hi JS, the ProRealTime Programming guide writes ( page 15):
    IF Close > Average[20](Close) THEN

    Result = 1

    ENDIF

    and comments: IF Price > 20-period moving average then Result is 1, otherwise Result = 0.

    The way I read it, the Result is always put back to 0 . Why is this wrong?

     

    #202909

    If have written the code for using two timeslots to trade and two other slots to end the trade. This code works.

    // Twee timeslots om te handelen

    TimeSlot1 = 0

    TimeSlot2 = 0

    TimeSlot3 = 0

    TimeSlot4 = 0

     

    If OpenTime >= 083000 and OpenTime < 110000 then

    TimeSlot1 = 1

    ElsIF OpenTime >= 110000 and OpenTime < 150000 then

    TimeSlot2 = 1

    ElsIf OpenTime >= 150000 and OpenTime < 163000 then

    TimeSlot3 = 1

    ElsIf OpenTime >= 163000 and OpenTime <= 220000 then

    TimeSlot4 = 1

    EndIf

     

    //Conditie timeslots

    c1 = TimeSlot1 = 1 OR TimeSlot3 = 1

    c2 = TimeSlot2 = 1

    c3 = TimeSlot4 = 1

     

    For opening a long or shorttrade the c1 is added. For closing the positions when the time is finished add c2 OR c3 to the exitcode.

    #202910

    That statement is incorrect, that code will only set RESULT to 1 when the condition is evaluated true, otherwise RESULT will remain unchanged.

    Set RESULT=0 before that code snippet.

     

    1 user thanked author for this post.
    #203325

    I have no idea what you are saying Roberto. The above code from day 10/21 is working. It does not speak about a RESULT. And what means “before that snippet”?

    #203327
    JS

    Hi @Vogeltje

    Roberto’s comment was about your previous statement.

    If Close > Average[20](Close) then

    Result = 1

    EndIf

    It was about “automatically” restoring Result = 1 to Result = 0

    As you probably already know, the restore is not “automatic” but you have to reset the result to 0 yourself before the start of your code (code snippet) with for example:

    Result = 0

    If Close > Average[20](Close) then

    Result = 1

    EndIf

    2 users thanked author for this post.
    #203473

    a ha! Thanks JS, great!

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

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