I’m today facing a problem I can’t explain… In order to set trading times with ProBuilder, I usually use this code which works for me:
For instance
1
2
3
4
5
6
7
// x is a value returned at the end
MyCondition=Time<090000ANDTime>190000
IFMyConditionTHEN
x=0
ENDIF
Right here, I believe we’ll all agree, but in my code I can’t set these “time preferences” (not before 090000 and not after 190000). I can let it run during the night very easily (from 190000 to 090000), or if I set the values I want, then it seems to ignore them.. There’s a mistake somewhere and if anyone could help me it would be amazing!
Here’s my code “not caring” about my time preferences :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
TradingTimes=190000<TimeANDTime<090000
// Allowing trading
IFVolatilityConditionsTHEN
allows=1
ELSE
allows=0
ENDIF
// Long loop
IF(x<>0)AND(High<(x+0.0012))THEN
y=0
ELSE
x=0
ENDIF
// Short loop
IF(y<>0)AND(Low>(y-0.0012))THEN
x=0
ELSE
y=0
ENDIF
IFTradingTimesTHEN
x=0
y=0
ELSE
IFallowsTHEN
// Long opening
c1=(pSAR[1]>High[1])
c2=(High>pSAR[1])
IFc1ANDc2THEN
x=pSAR[1]
ENDIF
// Short opening
c3=(pSAR[1]<Low[1])
c4=(Low<pSAR[1])
IFc3ANDc4THEN
y=pSAR[1]
ENDIF
ENDIF
ENDIF
RETURNx,y
PS : I’m trying to build a strategy with this code as indicator, that’s why it might seem totally useless so far but I can’t start backtesting to improve it before fixing this time issue… (it’s obviously messing up all the startegy).
A variable can’t be simultaneously lower than 90000 and higher than 190000, even if in your mind it’s a continuous clock time ending at 240000 with continuity at 0, in the space of real numbers what your really want for night trading times is a subset made of 2 distinct intervals [0;090000] [190000;240000], so try replacing your “and” with “or”:
Thank you so much! It works perfectly! I think I’ve been working on it for too long, and I couldn’t see anything anymore. Thank you so much once again.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok