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

Double Stop Loss Order Submittal Resulting in Unintended Entry

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

    Double Stop Loss Order Submittal Resulting in Unintended Entry

    I considered posting this to Tech Support, but decided to post here. I had a code malfunction today needing manual handling, which I always want to avoid. I had a scenario where my stop loss order was triggered, and entered the order queue "working." There was an in-process volatility/volume spike in CL, forcing a fairly large amount of slippage. I am confident OnBarUpdate was triggered during the working time due to the fill price. What I need to know is this: if SetStopLoss is called in OnBarUpdate and if there is a working stop loss order while OnBarUpdate is called, will another be submitted? Is this working as intended? Or did I actually force it to happen in my code?

    I have this code placed in OnExecutionUpdate, intended to reset stop loss orders to its default value once executed. This seems like a likely culprit. Would this cause this to happen?

    Code:
    if (execution.Order.Name == "Stop loss")
    {
    SetStopLoss("", CalculationMode.Ticks, stoplosss, true);
    shiftstop = false;
    trailingstop = false;
    considerexit = false;
    }
    stoplosss = System.Convert.ToInt32(stoploss * atrbalance * SMAatr[0]);

    #2
    Hello liquid150 ,

    if SetStopLoss is called in OnBarUpdate and if there is a working stop loss order while OnBarUpdate is called, will another be submitted?
    If you have a working stoploss it should update the existing order if the same fromEntrySignal is used.

    I have this code placed in OnExecutionUpdate, intended to reset stop loss orders to its default value once executed. This seems like a likely culprit. Would this cause this to happen?
    That could be, can you explain further what this is intended to do?

    Right now, if the order "Stop loss" has an execution event, it will try to submit a stop loss. If there was an existing order it would try to update it however if you did this for a fill I am not certain what the result of that would be offhand.

    Are you trying to reset the stoplosss price which is used for the next stop order that will be submitted sometime in the future? If so, you likely just need to remove the SetStopLoss line, that would only be used to initially submit/update working orders.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello liquid150 ,



      If you have a working stoploss it should update the existing order if the same fromEntrySignal is used.
      Okay so just to confirm, this is "Working" state meaning working in order queue, yes? If so then I think the posted code is the issue.


      Originally posted by NinjaTrader_Jesse View Post
      That could be, can you explain further what this is intended to do?

      Right now, if the order "Stop loss" has an execution event, it will try to submit a stop loss. If there was an existing order it would try to update it however if you did this for a fill I am not certain what the result of that would be offhand.

      Are you trying to reset the stoplosss price which is used for the next stop order that will be submitted sometime in the future? If so, you likely just need to remove the SetStopLoss line, that would only be used to initially submit/update working orders.

      I look forward to being of further assistance.
      Yes, I am resetting stoplosss price for use in the future, along with all the booleans which can potentially affect it.

      Comment


        #4
        Hello liquid150,

        Okay so just to confirm, this is "Working" state meaning working in order queue, yes?
        Correct, the order state will literally say "working".

        It sounds like have likely narrowed in on the problem, if the intention is just to reset the price/variables for the future the SetStopLoss is not needed there. You only need to call SetStopLoss if you want to submit an order or update one, for example you could make a trailing stop by calling this with new prices.

        If that ends up not being the problem, please let me know and we can continue to look into it.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by frankthearm, Today, 09:08 AM
        7 responses
        30 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by NRITV, Today, 01:15 PM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by maybeimnotrader, Yesterday, 05:46 PM
        5 responses
        25 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by quantismo, Yesterday, 05:13 PM
        2 responses
        18 views
        0 likes
        Last Post quantismo  
        Started by adeelshahzad, Today, 03:54 AM
        5 responses
        33 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X