Trading opening gap

Viewing 15 posts - 1 through 15 (of 19 total)
  • #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
    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

    Add 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.
    #227309

    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 !

     

    #227311

    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

    I’ll try your code on my Platform

    #227313

    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?

     

    1 user thanked author for this post.
    #227314

    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 🙂

    1 user thanked author for this post.
    #227318

    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

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

    1 user thanked author for this post.
    #227408

    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

    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

    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

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

    #227438

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

    Did you try it also?

     

    #227456

    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)

Create your free account now and post your request to benefit from the help of the community
Register or Login