Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

If order not filled

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

    If order not filled

    Hello,

    I want to ask please how I can code

    "if Target (iorder) not filled at target price"
    then do........

    and also

    "if entry (limitorder) not filled at limit price"
    then do

    Couldn´t find a thread about this in the forum.

    Thank you
    Tony

    #2
    Hello,
    Thank you for your post.
    You could do this by assigning a variable to your target price and limit price then checking in OnExexcution().

    For example:
    Code:
    #region Variables
        IOrder longEntry;
        IOrder longTarget;
        private double entryPrice = 0.0;
        private double targetPrice = 0.0;
    #endregion
    
    protected override void OnBarUpdate()
    {
        entryPrice = //desired entry price
        targetPrice = //desired entry price
        if (/ conditions to place entry /)
        {
            longEntry = EnterLongLimit(Price);
        }
    
        if (longEntry != null && longEntry.OrderState == OrderState.Working)
        {
            // entry is working
        }
        if (longTarget != null && longTarget.OrderState == OrderState.Working)
        {
            // target is working 
        }
    }
    
    OnExecution(IExecution execution)
    {
        If (execution.Order == longEntry)
        {
            longTarget = EnterLongLimit(Price);
        }
        if(execution.Order == longEntry && execution.Price != entryPrice)
        {
           //longEntry filled at different price than submission price
        }
        if(execution.Order == longTarget && execution.Price != targetPrice)
        {    
            //longTarget filled at different price than submission price
    }
    If we can be of any other assistance please let us know.
    Cody B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    115 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    161 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    83 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    127 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    87 views
    0 likes
    Last Post PaulMohn  
    Working...
    X