Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Detecting PartFills and it's simulation.

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

    Detecting PartFills and it's simulation.

    Dear Support.

    I just want to be sure that I do correct things in my strategy and want to ask you some questions, if you don't mind

    1. As I understand there is no way to simulate partial fills on back-testing?
    2. Inside onExecution method: what is difference between Order.Filled, order.Quantity and Position.Quantity at one point of time?
    E.g. I work with single entry for 10 lots. First fill was at 5 lots:
    Code:
    Order.Filled = 5, order.Quantity = 10, Position.Quantity=5, Order.OrderState == OrderState.PartFilled.
    The second fill was 5 lots too (5+5 = 10 lots total):
    Code:
    Order.Filled = 10, order.Quantity = 10, Position.Quantity=10, Order.OrderState != OrderState.PartFilled ( PartFilled ==false ).
    The problem that I want to be sure that I send correct numbers of stop order lots. Please take a look at it:
    Code:
    protected override void OnExecution(IExecution execution)
    {
        IOrder order = execution.Order;
                
        if (_EntryLongOrderId != null && _EntryLongOrderId == order && order.OrderState == OrderState.Filled)
        {                
             if (order.OrderState != OrderState.PartFilled) 
                _EntryLongOrderId = null;
    
            SendBracketsLong("Orig"); //using Position.Quantity inside
        }
        if (_EntryShortOrderId != null && _EntryShortOrderId == order && order.OrderState == OrderState.Filled)
        {                
             if (order.OrderState != OrderState.PartFilled) 
                 _EntryShortOrderId = null;
                    
            SendBracketsShort("Orig"); //using Position.Quantity inside
        }
    }

    #2
    Hello AlexFdv,

    Thank you for your post.

    1. You can simulate partial fills with the use of a simulated intra-bar fill. For information on this and a reference sample please visit the following link: http://www.ninjatrader.com/support/f...ead.php?t=6652

    2. For information on the different IOrder parameters please visit the following link: http://www.ninjatrader.com/support/h...nt7/iorder.htm
    For information on the different IPosition parameters please visit the following link: http://www.ninjatrader.com/support/h.../iposition.htm

    I also recommend reviewing our OnOrderUpdate() and OnExecution() reference sample: http://www.ninjatrader.com/support/f...ead.php?t=7499

    Please let me know if you have any questions.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CarlTrading, 03-31-2026, 09:41 PM
    1 response
    67 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    36 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    59 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    62 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    53 views
    0 likes
    Last Post CarlTrading  
    Working...
    X