• 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

  • 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 Aporshnev, Today, 05:56 PM
0 responses
1 view
0 likes
Last Post Aporshnev  
Started by aslane, Today, 05:46 PM
0 responses
2 views
0 likes
Last Post aslane
by aslane
 
Started by Aporshnev, Today, 04:31 PM
1 response
5 views
0 likes
Last Post NinjaTrader_ShawnB  
Started by tradykat, Yesterday, 05:09 PM
7 responses
35 views
0 likes
Last Post NT-Roland  
Started by PLeary, Today, 03:09 PM
2 responses
20 views
0 likes
Last Post PLeary
by PLeary
 
Working...
X