How do I create a Limit-On-Open Order for backtesting?

Forums ProRealTime English forum ProOrder support How do I create a Limit-On-Open Order for backtesting?

Viewing 5 posts - 1 through 5 (of 5 total)
  • #31409

    I want to backtest buying at a Limit Price, but only on the Open.

    Example: I want to buy 100 shares on today’s Open, but only if today’s Open is at yesterday’s Close or Less. I don’t want to buy if today opens above yesterday’s Close, and then during the day the price drops down to the limit price. I want it to occur only on the Open, and if it doesn’t, then I want it to be disregarded.

    What is the coding for that?

    Thank you,

    Jack

    #31421

    Just my initial thoughts, guess you tried similar to below?

    ‘GH code’ to save me thinking / finding the correct syntax …

    If DOpen <= DClose[1] Then
    Set BuyStop at DOpen
    Endif

    Code is only read at the end of a bar and the Buy / Sell Short / Exit is completed at the beginning of the next bar … I guess you know that? So depending on what Timeframe you are using the Price may very well have zoomed past the DOpen level so best you allow some %, i.e. DOpen + 5*pipsize or whatever?

    Also did you know that – as a general rule – most Up days start with the Day Open > Day Close yesterday and if it is a big range UP day then that day will finish close to / on the High of the day.

    Just a few thoughts
    GraHal

    #31432

    Sitting in the garden in the sun and my answer flicked through my mind! 🙂

    You can’t read Daily Open Price until at least 1 bar has closed after the Daily Open (code is read at the end of bars) and so you would need to be on TimeFrame 1 Min or less else Price may run away and you would never get a Buy at or near the Open.

    Here’s a question … when is the Daily Open anyway? Is it at 120001 (a new day / date) in the Timezone of the market or is it at the Market Open for the Timezone? So Dax Open is 090000 CET?? Anybody??

     

    #31519

    Thank you GraHal for your suggestion. But that doesn’t seem to do what I’m wanting.

    Another way of stating what I’m trying to do is:

    I want to buy 100 shares on tomorrow’s Open, but only if tomorrow’s Open is at today’s Close or Less. I don’t want to buy if tomorrow opens above today’s Close, and then during tomorrow the price drops down to the limit price. I want the buy to occur only on the Open, and if it doesn’t, then I want it to be disregarded.

    Here is what I have so far:

    IF c1 AND c2 AND c3 THEN
    BUY 100 shares AT CLOSE limit
    ENDIF

    What I don’t know, is how to limit the order to only to be filled on the Open of tomorrow.

    Thank you,

    Jack

     

    #31586

    Hi Jack

    There is no code for Tomorrow Open so 1 bar needs to have closed tomorrow so that code can decide if Todays Open was <= Yesterday Close

    If DOpen <= DClose[1] Then
    BUY 100 shares AT CLOSE limit
    ENDIF

    I’ll have a think about … buy to occur only on the Open, and if it doesn’t, then disregard … my grandson is here so  I have to get off my computer 🙂

    GraHal

Viewing 5 posts - 1 through 5 (of 5 total)

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