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 judysamnt7, 03-13-2023, 09:11 AM
    4 responses
    59 views
    0 likes
    Last Post DynamicTest  
    Started by ScottWalsh, Today, 06:52 PM
    4 responses
    36 views
    0 likes
    Last Post ScottWalsh  
    Started by olisav57, Today, 07:39 PM
    0 responses
    7 views
    0 likes
    Last Post olisav57  
    Started by trilliantrader, Today, 03:01 PM
    2 responses
    21 views
    0 likes
    Last Post helpwanted  
    Started by cre8able, Today, 07:24 PM
    0 responses
    10 views
    0 likes
    Last Post cre8able  
    Working...
    X