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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    157 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    91 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    143 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    130 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    107 views
    0 likes
    Last Post CarlTrading  
    Working...
    X