Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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:


  • 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 elirion, Today, 01:36 AM
0 responses
3 views
0 likes
Last Post elirion
by elirion
 
Started by gentlebenthebear, Today, 01:30 AM
0 responses
4 views
0 likes
Last Post gentlebenthebear  
Started by samish18, Yesterday, 08:31 AM
2 responses
9 views
0 likes
Last Post elirion
by elirion
 
Started by Mestor, 03-10-2023, 01:50 AM
16 responses
391 views
0 likes
Last Post z.franck  
Started by rtwave, 04-12-2024, 09:30 AM
4 responses
34 views
0 likes
Last Post rtwave
by rtwave
 
Working...
X