Trading opening gap

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #227304 quote
    upupandaway
    Participant
    New

    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
    ENDIF

    I suspect that this line is what makes no sense for PRT, however it does for me:

    OpeningGapPercentage = (Open – Close[1]) / Close[1]

    #227308 quote
    GraHal
    Participant
    Master

    Add below to the end of your code and look for 1 when the condition is True

    GRAPH OpeningGapPercentage > 0.002

    upupandaway thanked this post
    #227309 quote
    PeterSt
    Participant
    Master

    Hi 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.000268

     

    I 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 !

    image_2024-02-02_122619556.png image_2024-02-02_122619556.png
    #227311 quote
    upupandaway
    Participant
    New

    Thanks! Your code let mi find the cases where the condition is True, however it does not enter any trade… I don’t know why.

    #227312 quote
    GraHal
    Participant
    Master

    I’ll try your code on my Platform

    #227313 quote
    GraHal
    Participant
    Master

    I 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?

    upupandaway thanked this post
    #227314 quote
    upupandaway
    Participant
    New

    I 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 🙂

    GraHal thanked this post
    #227318 quote
    GraHal
    Participant
    Master

    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.

    Above is misleading and confusing.

    From my test … Your Condition is NOT true at 090000.

    What Instrument are you running your code against?

    #227330 quote
    GraHal
    Participant
    Master

    Try your code at 090100 … let us know the results?

    upupandaway thanked this post
    #227408 quote
    upupandaway
    Participant
    New

    I 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.

    #227411 quote
    upupandaway
    Participant
    New

    But 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.)

    #227412 quote
    upupandaway
    Participant
    New

    Oh, 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
    ENDIF

    #227422 quote
    upupandaway
    Participant
    New

    Come to think of it; maybe this topic should be moved to the ProBuilder forum?

    #227438 quote
    GraHal
    Participant
    Master

    I tried below and it never showed True / 1.  So this is why you never get a trade.

    Did you try it also?

    GRAPH Time = 090000 AND OpeningGapPercentage > 0.002
    #227456 quote
    upupandaway
    Participant
    New

    Yes I did. With 200 k units on one minute timeframe I get four instances where it is true.

Viewing 15 posts - 1 through 15 (of 19 total)
  • You must be logged in to reply to this topic.

Trading opening gap


General Trading: Market Analysis & Manual Trading

New Reply
Author
Summary

This topic contains 18 replies,
has 4 voices, and was last updated by PeterSt
1 year, 11 months ago.

Topic Details
Forum: General Trading: Market Analysis & Manual Trading
Language: English
Started: 02/02/2024
Status: Active
Attachments: 3 files
Logo Logo
Loading...