Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Should orders fill at the bid/ask price? Not Close[0] price?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Should orders fill at the bid/ask price? Not Close[0] price?

    I'm back testing on a volatile day to make sure my strategy is placing stops in valid positions. I'm calculating on each tick. I'm checking the Close[0], GetCurrentAsk(), and GetCurrentBid(). If I understand correctly, the market is really at the Bid/Ask value, not the Close[0] value. Close[0] is the last traded price. The example I'm working on now, the market is moving down and then makes a quick jump up. I get the values below.


    double ask = GetCurrentAsk(); =5502
    double bid = GetCurrentBid(); =5501.75
    double currentPosition = Close[0];​ =5500

    I'm submitting an unmanaged market order to enter the market using ActiveOrder = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, OrderQuantity);

    I check, and confirm, the average fill price is at the ask, 5502.

    Then I submit an unmanaged stop loss order one point below my entry location at 5501.

    stopLossOrder = SubmitOrderUnmanaged(0, OrderAction.Sell, OrderType.StopMarket, OrderQuantity, 0, 5501);

    The problem is, the stop loss order is immediately being filled at the Close[0] value of 5500. Is this just a characteristic of order fill simulation in back testing or will this happen in real time as well? Shouldn't the bid/ask value have to come down to 5501 to trigger the stop loss order?

    Last edited by lahmannjohn; 09-07-2024, 03:56 PM.

    #2
    Hello lahmannjohn,

    The bar prices are used directly in a backtest for fills so Close should be used in addition to other bar values to help calculate the prices for fills.



    I couldnt say if that will also happen in realtime, you would have to test the strategy and see if when the stop is submitted if it is filled right away.


    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    20 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    119 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    63 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    41 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    45 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X