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

Entries per Direction and Exits

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

    Entries per Direction and Exits

    Hi -

    I have a strategy that creates up to 4 orders per signal in a direction (long or short), a trade set for long or short signals. Each order (trade) has its own unique identifier (i.e. BarNumber+n+L or BarNumber+N+S where "n" is 1, 2, 3 or 4).

    A trade "closes" when it's stopped out, profit target hit, or a counter signal is generated.

    Ok, so here's my question...

    Is there a way to identify the individual trade when it "closes"? I've noticed that closed trades are either individually closed (i.e. stopped out or profit target achieved) -- and/or closed out together in one bundle, on one trade order (i.e. if 4 long trades then all 4 are closed out -- or sometimes 3 of 4, etc...).

    I've looked into OnExecutionUpdate and OnOrderUpdate to see if I can identify the entry signals to the exit signals, but trades can be individually closed or closed in a group.

    I have an external database that I've setup to log all entries and exits and I'm trying to tie the trade pairs together for reporting purposes.

    Thanks,

    Big Surf
    Last edited by bigsurftrader; 03-08-2017, 09:36 AM.

    #2
    More information:
    1) A trade set gets triggered by a signal. So, all orders are sent on the same bar on bar open
    2) It appears that NT submits orders individually, so if there are 3 "market" long orders NT treats them as 3 separate orders; however...
    3) When all three trades get closed out at the same time they are closed as a single order

    I have working solution for this by using OnOrderUpdate where I can filter "orderState=Filled" and then determine which trades, individually, got closed -- but, was wondering if there was a cleaner solution to what I"m looking for.

    Comment


      #3
      Hello bigsurftrader,

      Thank you for writing in.

      I have put together a sample strategy which assigns an order object to 3 different enter long methods, then within OnOrderUpdate, assigns a order object to the profit target and stop loss submitted as part of each entry. Then within OnBarUpdate you can check the OrderState of each order object to determine specificly if an entry position is open or closed.

      After putting this together I realized it sounds like you already found this solution. I am unaware of another alternative to this approach.

      Please let us know if you need further assistance.
      Attached Files
      Alan P.NinjaTrader Customer Service

      Comment


        #4
        ah!!!!! Thank you. I was doing something else :-)

        BigSurf

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by terofs, Yesterday, 04:18 PM
        1 response
        21 views
        0 likes
        Last Post terofs
        by terofs
         
        Started by CommonWhale, Today, 09:55 AM
        1 response
        3 views
        0 likes
        Last Post NinjaTrader_Erick  
        Started by Gerik, Today, 09:40 AM
        2 responses
        7 views
        0 likes
        Last Post Gerik
        by Gerik
         
        Started by RookieTrader, Today, 09:37 AM
        2 responses
        13 views
        0 likes
        Last Post RookieTrader  
        Started by alifarahani, Today, 09:40 AM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X