Trading two timeslots per day
Forums › ProRealTime English forum › ProBuilder support › Trading two timeslots per day
- This topic has 11 replies, 4 voices, and was last updated 2 years ago by Vogeltje.
-
-
09/12/2022 at 6:28 PM #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!
09/12/2022 at 8:00 PM #20065809/13/2022 at 8:27 AM #20067309/14/2022 at 1:58 PM #200792Thanks 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….
09/14/2022 at 3:58 PM #200803If 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.
09/14/2022 at 4:31 PM #20080510/21/2022 at 2:21 PM #202907Hi JS, the ProRealTime Programming guide writes ( page 15):
IF Close > Average[20](Close) THENResult = 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?
10/21/2022 at 4:52 PM #202909If 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.
10/21/2022 at 4:54 PM #202910That 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.
10/31/2022 at 7:07 PM #20332510/31/2022 at 7:56 PM #203327Hi @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.
11/03/2022 at 11:58 AM #203473 -
AuthorPosts
Find exclusive trading pro-tools on