Exact order price

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #58791 quote
    Mansoor
    Participant
    Average

    Hello Prorealtimers!

    When exactly does a buy occur after a buy condition is satisfied in a code? Say for example, in a 1 minute timeframe, at candle n buying condition is satisfied, does the buy order go to market as soon as the condition is satisfied, i.e. in the middle of bar n? or does it occur at the open of bar n+1?

    #58796 quote
    GraHal
    Participant
    Master

    does the buy order go to market as soon as the condition is satisfied? … yes if it is a Buy Limit or Buy Stop Order (and therefore at a predefined price level set at the end of the previous bar).

    In the middle of bar? … intrabar only as above.

    Buy orders get filled at the open of the next bar after the bar where ‘condition are met’.

    Code is read at the end of each bar.

    GraHal

    Mansoor thanked this post
    #58801 quote
    Vonasi
    Moderator
    Master

    All decisions are made at the candle close and orders placed at the next candle open. If that includes setting a buy/sell limit/stop order then that is when it is sent to the market. They last one candle only and so will need to be sent again at the close of that candle if you want the order to stay on the market for longer than one candle.

    Mansoor thanked this post
    #59846 quote
    Mansoor
    Participant
    Average

    Ok imagine these 2 scenarios:
    Assume: x < y < z and u which could be higher or lower than z.

    Now let’s assume I have this in my code:
    Buy when close crosses over y

    Scenario1: Bar n opens at x and closes at z
    Scenario2: Bar n opens at x, goes up to z and then comes down and closes at x

    Now let’s assume bar n+1 opens at price u.

    Would the buy order be triggered and at what price?

    #59850 quote
    robertogozzi
    Moderator
    Master

    Scenario 1 is the sole where close has crossed over x, so the buy order at market will be executed immediately when bar n closes, just before bar n+1 opens (once called NEXTBAROPEN).

    Scenario 2 has no condition  true, since the crossing is evaluated at the closure and it did not happen at that very time. You could trigger it just changing the condition to high crosses over x, instead of close crosses over x, but still it would be triggered at the same time, not while the crossing occurs.

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

Exact order price


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Mansoor @mansoor Participant
Summary

This topic contains 4 replies,
has 4 voices, and was last updated by robertogozzi
8 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/10/2018
Status: Active
Attachments: No files
Logo Logo
Loading...