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

  • NinjaTrader_ChelseaB
    replied
    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.

    Leave a comment:


  • hgheith
    started a topic Unintended extra trade at Exist in real life account

    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.

Latest Posts

Collapse

Topics Statistics Last Post
Started by tonynt, Today, 10:15 AM
0 responses
5 views
0 likes
Last Post tonynt
by tonynt
 
Started by darthy, 08-21-2020, 03:39 PM
2 responses
25 views
0 likes
Last Post darthy
by darthy
 
Started by ballboy11, Today, 09:43 AM
1 response
5 views
0 likes
Last Post NinjaTrader_Jesse  
Started by rene69851, 08-17-2020, 07:30 PM
7 responses
45 views
0 likes
Last Post NinjaTrader_Heath  
Started by ntdev, Today, 04:35 AM
1 response
11 views
0 likes
Last Post NinjaTrader_Jesse  
Working...
X