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 usazencort, Today, 01:16 AM
    0 responses
    1 view
    0 likes
    Last Post usazencort  
    Started by kaywai, 09-01-2023, 08:44 PM
    5 responses
    603 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by xiinteractive, 04-09-2024, 08:08 AM
    6 responses
    22 views
    0 likes
    Last Post xiinteractive  
    Started by Pattontje, Yesterday, 02:10 PM
    2 responses
    21 views
    0 likes
    Last Post Pattontje  
    Started by flybuzz, 04-21-2024, 04:07 PM
    17 responses
    230 views
    0 likes
    Last Post TradingLoss  
    Working...
    X