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

Finding SL/TP order linked to an EnterLong()

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

    Finding SL/TP order linked to an EnterLong()

    Hello,

    I'm trying to find the target price of a SL/TP order that I set inside the OnExecutionUpdate event handler, but I have no reference saved to it (declare an Order field for it, for example), I'm trying to make it robust to work on multiple scenarios.
    I think the only case this wouldn't work is if I have multiple Entries per Direction
    Just wondering if there's a better alternative when not using these automatic Sets() methods.

    Code:
    var findOrderOfAnEntry = Orders.
    FirstOrDefault(x => x.Name == "SL Buy" && x.FromEntrySignal == "Buy" && //Search for a SL or a TP of a Buy
    x.OrderUpdates.All(y => y.Filled == 0) && //Not Filled
    x.OrderUpdates.Any(y => y.OrderState == OrderState.Working) && //Currently Working
    x.OrderUpdates.All(y => !y.OrderState.ToString().Contains("Cancel"))); //Not Cancelled, CancelPending, CancelSubmitted
    Edit: Sorry I think this would have to be placed under the strategy development section

    #2
    Hello Waxavi,
    You can use OnOrderUpdate and OnExecutionUpdate to find orders. There is a sample of locating orders here: https://ninjatrader.com/support/help...and_onexec.htm

    You can technically do what you are doing now however it would not be a good practice, instead it is suggested to use the passed in variables from the events as they come in, that will work with all brokers.

    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by rdtdale, Today, 01:02 PM
    0 responses
    1 view
    0 likes
    Last Post rdtdale
    by rdtdale
     
    Started by alifarahani, Today, 09:40 AM
    3 responses
    15 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by RookieTrader, Today, 09:37 AM
    4 responses
    18 views
    0 likes
    Last Post RookieTrader  
    Started by PaulMohn, Today, 12:36 PM
    0 responses
    5 views
    0 likes
    Last Post PaulMohn  
    Started by love2code2trade, 04-17-2024, 01:45 PM
    4 responses
    40 views
    0 likes
    Last Post love2code2trade  
    Working...
    X