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

ExitLong() and ExitShort() doesnt close StopLoss and ProfitTarget() orders

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

    #16
    Hello elliot5,

    Thanks for your message.

    CancelOrder is called on Order objects and Set methods do not return Order objects. Also considering their function to pep NinjaTrader to submit orders for target/stop upon execution, and their internal behavior to update based on the Calculate mode, I would not suggest assigning a stop loss or profit target order submitted with a Set method to an Order object and attempt to cancel it.

    If you want to deliberately cancel a stop loss order or profit target order, I suggest using Exit methods or the Unmanaged Approach and assigning Order objects there and then cancelling those order objects.

    An example that demonstrates using Exit methods for target/stop and also demonstrates using Order objects is linked below.

    SampleOnOrderUpdate - https://ninjatrader.com/support/help...and_onexec.htm

    CancelOrder - https://ninjatrader.com/support/help...ancelorder.htm

    Calling ExitLong() or ExitShort() will close the position and cancel active orders. You will need to make sure that no FromEntrySingal string is provided and the Exit method is called for the proper BarsInProgress index to ensure that specific position and the stop loss/profit target tied to that entry are closed. If you specify a FromEntrySignalName, the Exit method will only affect what is tied to that entry signal name.

    If you are observing behavior where the Exit method is not closing the position and canceling orders when a blank FromEntrySignal string is provided and the Exit method is submitted to the proper BarsInProgress index, please provide a reduced example that demonstrates the behavior so we can report it.

    We look forward to assisting.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Market1337, Today, 08:54 AM
    0 responses
    10 views
    0 likes
    Last Post Market1337  
    Started by Bobin, Today, 04:29 AM
    1 response
    11 views
    0 likes
    Last Post bltdavid  
    Started by Lyubomir Kratinov, Today, 06:36 AM
    2 responses
    13 views
    0 likes
    Last Post Lyubomir Kratinov  
    Started by joostb, Today, 12:59 AM
    2 responses
    12 views
    0 likes
    Last Post joostb
    by joostb
     
    Started by Shai Samuel, Today, 02:35 AM
    0 responses
    12 views
    0 likes
    Last Post Shai Samuel  
    Working...
    X