• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unintended extra trade at Exist in real life account

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

    Unintended extra trade at Exist in real life account

    I have a strategy that updates stopPrice and targetPrice. When I use it in Real Life account, 75% of the time it Exists with entring an extra trade. I depend on two routines to mange the trade, one of them is to update the exit prices and the other is the OnExecution. It seems that there is a time delay between submitting-working-Filling the Exit and submitting an updated price orders and I always end with two executions instead of just Existing. This does not happen in the SIM101 account or Playback account.

    I really appreciate any suggestion. I have lost lot of $$ due to this unexpected behavior since I am not able to regenerate it in simulations..

    Here is an extract from the strategy (stop1 and target1 are Order). There might be several non-needed tests but I was trying several options to solve the issue.

    private void ManageOrders()
    (calculate new stopPrice and TargetPrice)
    if(newSpPr != stopPr)
    {
    stopPr = newSpPr;
    if(stopPr < GetCurrentBid(instID))
    {
    if(stop1 != null) {CancelOrder(stop1); stop1 = ExitLongStopMarket(instID, true, qtty1, stopPr, Name + "_" + "LgSp1", Name + "_" + "LgEn1");}
    }
    else
    {
    if(stop1 != null) {CancelOrder(stop1); stop1 = ExitLongLimit(instID, true, qtty1, stopPr, Name + "_" + "LgSp1", Name + "_" + "LgEn1");}
    }
    }
    if(newT1Pr != target1Pr)
    {
    target1Pr = newT1Pr;
    if(target1 != null) {CancelOrder(target1); target1 = ExitLongLimit(instID, true, qtty1, target1Pr, Name + "_" + "LgTg1", Name + "_" + "LgEn1");}
    }

    Then

    protected override void OnExecutionUpdate(..)
    #region cancel Stop or Target orders if the other is filled
    if(execution.Order.OrderState == OrderState.Filled)
    {
    if(execution.Name == Name + "_" + "LgSp1") {CancelOrder(stop1); stop1 = null; if(target1 != null) {CancelOrder(target1); target1 = null;}
    if(execution.Name == Name + "_" + "LgTg1") {CancelOrder(target1); target1 = null; if(stop1 != null) {CancelOrder(stop1); stop1 = null;}
    }
    Last edited by hgheith; 06-03-2017, 03:44 AM.

    #2
    Hello hgheith,

    Thank you for your note.

    This would depend on what orders are all working and when orders are submitted. Are you allowing for multiple exit orders to be working at the same time? If so, the would be subject to inflight executions.

    Are you waiting in OnOrderUpdate for an order to be in OrderState.Cancelled and then attempting to submit a new order?
    Last edited by NinjaTrader_ChelseaB; 06-04-2017, 07:07 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Oceans, Today, 02:22 AM
    1 response
    17 views
    0 likes
    Last Post NinjaTrader_PatrickG  
    Started by sisenberg, Yesterday, 08:06 PM
    1 response
    14 views
    0 likes
    Last Post sisenberg  
    Started by PLeary, Today, 06:25 AM
    0 responses
    4 views
    0 likes
    Last Post PLeary
    by PLeary
     
    Started by sergey_z, Today, 06:17 AM
    0 responses
    1 view
    0 likes
    Last Post sergey_z  
    Started by nikkk, Today, 06:14 AM
    1 response
    2 views
    0 likes
    Last Post NinjaTrader_PatrickG  
    Working...
    X