Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Replace Stop-Limit with a limit order if order gets skipped

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

    Replace Stop-Limit with a limit order if order gets skipped

    Hi,

    I have a custom order entry indicator where I can push a button and it creates a stop-limit order based on my logic at a certain price.

    Offset ticks for the stop-limit order is 0 so it happens from time to time that the order gets skipped.

    Is there a way to program my indicator that it can detect (assuming a long entry) that if current price is higher than the stop-limit order -> replace stop-limit with a limit order at the same price? How would I go about it?

    Thanks!

    #2
    Hello Orion1504,

    If you are submitting an order using the addon approach in an indicator, this would mean the order is being assigned to a variable before being supplied to <Account>.Submit().

    You can check the state of the order held by the variable and the price.

    if (myOrderVariable != null && myOrderVariable.OrderState == OrderState.Working && Close[0] > myOrderVariable.StopPrice)
    {
    CancelOrder(myOrderVariable);
    }

    In the <Account>.OrderUpdate event handler method:

    if (e.Order == myOrderVariable && myOrderVariable.OrderState == OrderState.Cancelled)
    {
    replacementOrder = mAccount.CreateOrder(Instrument, OrderAction.Sell, OrderType.Limit, OrderEntry.Automated, TimeInForce.Day, 1, 0, 1400, string.Emtpy, "limitOrder", Core.Globals.MaxDate, ull);
    myAccount.Submit(new Order[] { replacementOrder } );
    }
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    150 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    303 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    243 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    345 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    174 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X