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 DanielTynera, Today, 01:14 AM
    0 responses
    2 views
    0 likes
    Last Post DanielTynera  
    Started by yertle, 04-18-2024, 08:38 AM
    9 responses
    40 views
    0 likes
    Last Post yertle
    by yertle
     
    Started by techgetgame, Yesterday, 11:42 PM
    0 responses
    12 views
    0 likes
    Last Post techgetgame  
    Started by sephichapdson, Yesterday, 11:36 PM
    0 responses
    2 views
    0 likes
    Last Post sephichapdson  
    Started by bortz, 11-06-2023, 08:04 AM
    47 responses
    1,615 views
    0 likes
    Last Post aligator  
    Working...
    X