Trading opening gap
Forums › ProRealTime English forum › General trading discussions › Trading opening gap
- This topic has 18 replies, 4 voices, and was last updated 9 months ago by PeterSt.
-
-
02/02/2024 at 11:25 AM #227304
Hi! I have tried making a code that identifies opening gaps that are larger than 0.2%, and the strategy goes short when that condition is met, but the code returns no trades even on a period where I know there has been such gaps. Here is the code:
OpeningGapPercentage = (Open – Close[1]) / Close[1]
// Short condition: more than 0.2% up
IF Time = 090000 AND OpeningGapPercentage > 0.002 THEN
SELLSHORT AT MARKET
ENDIFI suspect that this line is what makes no sense for PRT, however it does for me:
OpeningGapPercentage = (Open – Close[1]) / Close[1]
02/02/2024 at 12:26 PM #227308Add below to the end of your code and look for 1 when the condition is True
GRAPH OpeningGapPercentage > 0.002
1 user thanked author for this post.
02/02/2024 at 12:32 PM #227309Hi there,
Here I have a random candle on Nasdaq. Is has changed (dropped !) 0.03%.
17516.7 – 17512.1 = 4.7
4.7 / 17512.1 = 0.000268I suspect that this line is what makes no sense for PRT, however it does for me:
Haha. 🙂
Of course I am using a 1 minute bar and if yours is about a day then it may work. But for now you’re a factor 100 off.If you think it is still fine, consider what you actually want. Must the price have risen the 0.02% or must or have dropped. You can have that upside down, accidentally.
Have fun !
02/02/2024 at 12:57 PM #227311Thanks! Your code let mi find the cases where the condition is True, however it does not enter any trade… I don’t know why.
02/02/2024 at 1:11 PM #22731202/02/2024 at 1:16 PM #227313I can see it straight away … your condition to SellShort is True ONLY at 090000 so by time the code executes and then next bar opens (to execute the SellShort) it is no longer 090000.
Wow … this sauerkraut I’m eating is really sharpening my brain up!!! HAHAHAHH
What TF are you running your code on?
1 user thanked author for this post.
02/02/2024 at 2:02 PM #227314I see. I’m using one minute timeframe, because I want the strategy to act promptly after the condition is True.
I’m happy to hear that sauerkraut helps you 🙂 Perhaps I should try it too 🙂
1 user thanked author for this post.
02/02/2024 at 2:34 PM #227318your condition to SellShort is True ONLY at 090000 so by time the code executes and then next bar opens (to execute the SellShort) it is no longer 090000.
Above is misleading and confusing.
From my test … Your Condition is NOT true at 090000.
What Instrument are you running your code against?
02/02/2024 at 4:02 PM #227330Try your code at 090100 … let us know the results?
1 user thanked author for this post.
02/05/2024 at 9:28 AM #227408I don’t really see the point. The same thing would happen (or not happen) again, only one minute later?
But I tried it anyway, and there is really no big difference; the condition is True on the same dates for the testperiod, and no trade is entered.
02/05/2024 at 9:53 AM #227411But I think the problem is this:
I’m running it on the DAX. PRT takes the price data from yesterday’s close (Close[1]) at midnight, and on most days the DAX is open also the next minute, which is when the ‘Open’ happens. Therefore, there is mostly no big difference between the prices (Open – Close[1]). And an OpeningGapPercentage that is > 0.002 only happens after perticular weekends when the Weekend Germany 40 has ben traded up during the weekend.
My real objective is actually to get the price data from 9:00 for Open and 17:30 for Close[1]. (At first, I thought that this is what Open/Close[1] means.)
02/05/2024 at 10:03 AM #227412Oh, and I forgot to tell you I use this code to get the daily close:
Timeframe (daily)
OpeningGapPercentage = (Open – Close[1]) / Close[1]And this code for the execution on the one minute timeframe:
// Short condition: more than 0.2% up
Timeframe (default)
IF Time = 090000 AND OpeningGapPercentage > 0.002 THEN
SELLSHORT AT MARKET
ENDIF02/05/2024 at 1:45 PM #227422Come to think of it; maybe this topic should be moved to the ProBuilder forum?
02/05/2024 at 7:41 PM #22743802/06/2024 at 9:41 AM #227456Yes I did. With 200 k units on one minute timeframe I get four instances where it is true.
-
AuthorPosts
Find exclusive trading pro-tools on