DEFPARAM PreLoadBars = 0
DEFPARAM FlatAfter = 215500
If (currenttime=160000) then
entry=1
else
entry=0
endif
// Conditions to enter long positions
IF NOT LongOnMarket AND entry=1 THEN
BUY 1 CONTRACTS AT MARKET
ENDIF
I wanna backtest a open drive failure strategy. I have managed to get the time entry condition to work but can’t seem to find a way to entry only if the opening price at 15:30 is
the highest at 16:00 since 15:30. I also wanna know if it is possible to set my target to the opening price of the 15:30 bar.
To clarify:
1: Is there a code to only entry the trade if 15:30 open is still the highest point in the last half hour?
2: Is it possible to set my target to the opening price of the 15:30 bar?
Hi Mikael I am not sure I understand you correctly about the opening at 15:30 but for the highest price between 15:30 and 16:00 you would need to run it on a specific timeframe- let say 15 min
it could be something like this- I didn’t test it though
cheers Kasper
if current time >=160000 and current time <=161500
tradetime=1
else
tradetime=0
endif
myhigh= highest[2]high (close)
if tradetime and open>myhigh then
buy 1 contract at market
endif
Hello! What I mean when I said opening at 15:30 is the opening price of the 15:30 bar. I look to use this strategy at the US opening in Sweden.
I tried to use the code you gave me and I think your are onto something but i get an error on 1 and 3. I tried to add “then after 161500 on line 1 but still gets the error.
I will look at it more this tonight but I appreciate you reply.
Cheers
Hi, it was a syntax error. I was not near PRT but wrote it from memory.. (not selling myself very well here- I know :-))
try this
if currenttime >=160000 and currenttime <=161500 then
tradetime=1
else
tradetime=0
endif
myhigh= highest[2](high)//is the highest"high" from the last two periods- which is 30 min- hence the 15 min timeframe. adjust accordingly
if tradetime and open>myhigh then
buy 1 contract at market
endif