Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

What's the best way to know when you're out of a trade?

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

    What's the best way to know when you're out of a trade?

    I'm developing a strategy where I get into one base trade--quite possibly a "long" running trade. i.e. I'm holding for 1-2 hours. During that time, I want to execute secondary trades.

    What I want to do is execute a secondary trade, but wait for it to finish before kicking off another secondary trade.

    Is there a direct way to connect a profit target/loss for a particular trade to some sort of callback function? I'm trying to figure out how to know when I'm out of a trade.

    #2
    You could work for example with a bool that you set / reset for entry executions based on your conditions for the secondary position, or more granular check for the IOrder object state - http://www.ninjatrader-support.com/H...V6/IOrder.html

    This would allow you to check if the exit orders for your entry signal name are filled and thus you could consider executing another secondary trade then.

    Comment


      #3
      Ok ... so when I do an EnterShort( ... ) or EnterLong( ... ) -- I understand I can capture the order, for example:
      myOrder = EnterLong( ... );

      Then in OnBarUpdate() I can check the OrderState...so something like:

      if (myOrder.OrderState == OrderState.Accepted)
      {
      // the order has been accepted
      }
      else if (myOrder.OrderState == OrderState.Cancelled)
      {
      // the order has been cancelled
      }
      // ...

      that makes sense to me...what I'm confused about is how do those OrderState values coorelate to the various stages of an order? From my perspective, an order goes through this cycle:
      1) order placed
      2) order filled
      3a) profit target hit
      3b) profit loss hit
      3c) explicit Exit initiated (happens at end of market day)


      Looking at the values of OrderState...which maps to (1), (2), (3a), (3b), (3c)?

      Does that question make sense? If I had to take a guess:
      (1) OrderState.Accepted
      (2) OrderState.Filled
      (3a)-(3c) OrderState.Cancelled

      I'm really not sure about the last one...and if that is correct, how can I tell if it exited b/c it hit the profit target or the profit loss?

      Thanks for whatever help you can provide here.

      Comment


        #4
        Originally posted by gv1150 View Post
        How can I tell if it exited b/c it hit the profit target or the profit loss?
        Hi gv1150, first of all your understanding of order states (PendingSubmit -> Accepted -> Working -> (Filled or Cancelled)) is correct.

        As for this second question, please see the sample named Monitoring Stop-Loss and Profit Target Orders.

        EDIT: Also, the quickest way to be notified of a change in an order's status would be to check in OnOrderUpdate(). This other sample - Using OnOrderUpdate() and OnExecution() - should be useful as well.
        Last edited by NinjaTrader_Austin; 12-03-2009, 03:21 PM.
        AustinNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X