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 kinfxhk, 07-14-2026, 09:39 AM
    0 responses
    122 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 10:18 AM
    0 responses
    104 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 09:50 AM
    0 responses
    82 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-13-2026, 07:21 AM
    0 responses
    102 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Started by kinfxhk, 07-11-2026, 02:11 AM
    0 responses
    82 views
    0 likes
    Last Post kinfxhk
    by kinfxhk
     
    Working...
    X