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 sjsj2732, Today, 04:31 AM
    0 responses
    20 views
    0 likes
    Last Post sjsj2732  
    Started by NullPointStrategies, 03-13-2026, 05:17 AM
    0 responses
    280 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    279 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    130 views
    1 like
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    90 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Working...
    X