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

Stop and Target remained after using ExitLong()

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

    Stop and Target remained after using ExitLong()

    Hello guys,

    I programmed my strategy to exit a position after reaching a max amount of gain. Today I was testing my strategy, I was in a long position, I reached my max gain, the strategy closed the position, but still the stop and target orders remained active. The function Im using to exit that position was ExitLong().

    ¿Does anyone know what could be causing this issue?

    Thank you!

    #2
    Hello facuevasm,


    There are some internal order handling rules to reduce unwanted positions, although these rules do not apply to market orders like ExitLong(). The rules may be found in the help guide here:Are the stop and target orders submitted via the Set() methods or do you use OnOrderUpdate() and OnExecution() to submit the protective orders? A stop loss or profit target from SetStopLoss() or SetProfitTarget() should automatically cancel once the managing position is closed by another strategy exit order. Please provide a snippet that shows how the stop loss and profit target orders are submitted in your strategy so I may better understand and assist you.

    I look forward to your reply.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Hi Emily, I'd like to join in on this thread. I have the same thing going on. Using Set() method. The position closes, PT and SL orders don't close. The window that pops up says in effect " Ninja tried to close the orders but it was rejected....etc". Then it automatically disables the strategy. But the Sell and Buy orders are still there and if I leave them, the orders are eventually hit and positions entered. This has only happened once with this strategy over more than 30 days of testing. But I need a fix before I run it live. Is there anything we can do about it? Thanks...

      Comment


        #4
        Hello JoeF1953,

        Thank you for your note.

        Who is your data provider? Did you contact your broker or the NinjaTrader support team when this occurred? How long ago did this happen? If an order is rejected, the default behavior for the platform is to stop the strategy, cancel any remaining working orders, and then close any open positions managed by the strategy. If the cancellations are submitted, they may or may not be accepted by your broker. If the cancellation fails, that could be considered to be an in-flight execution which is typically a rare occurrence. If you are coding an unlocked strategy in the NinjaScript error, you could consider creating your own custom order rejection logic by setting RealtimeErrorHandling to either StopCancelCloseIgnoreRejects or IgnoreAllErrors and then catch those rejection messages and set up logic to be executed when an error occurs. More information about RealtimeErrorHandling and In Flight Executions may be found at the following links:Since you received an error message, it is typically helpful to contact your broker for additional details as well as contact the NinjaTrader support team so we may review your diagnostic files and offer an analysis of what occurred. This can help to understand the situation better and come up with ways to potentially prevent it from happening again in the future.

        Thank you for your patience.
        Emily C.NinjaTrader Customer Service

        Comment


          #5
          Thanks Emily, that's exactly what I needed to know. Ninja is my broker. It happened a couple of days ago. It was on a Sim account with live data, but since it wasn't a live account I didn't panic about it. I think it must have been a connection issue and I'm dealing with in-flight execution. I'll review the links you posted and try to set up logic to be executed when an error occurs. Appreciate you guys!!!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by mishhh, 05-25-2010, 08:54 AM
          19 responses
          6,189 views
          0 likes
          Last Post rene69851  
          Started by gwenael, Today, 09:29 AM
          0 responses
          4 views
          0 likes
          Last Post gwenael
          by gwenael
           
          Started by Karado58, 11-26-2012, 02:57 PM
          8 responses
          14,830 views
          0 likes
          Last Post Option Whisperer  
          Started by Option Whisperer, Today, 09:05 AM
          0 responses
          2 views
          0 likes
          Last Post Option Whisperer  
          Started by cre8able, Yesterday, 01:16 PM
          3 responses
          11 views
          0 likes
          Last Post cre8able  
          Working...
          X