Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Managing Stoplosses/ProfitTargets of Multiple Entries

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

    Managing Stoplosses/ProfitTargets of Multiple Entries

    I'd like to thank you guys for wonderful job you did on maintaining this site!


    The senario is:

    • -We got an entry signal, then NT entered a trade, let's call Trade#1. Then NT places a Stop loss (SL#1) for Trade#1.
    • After a while, another entry signal, then NT entered another trade:Trade#2, submited another stop loss:SL#2 and mean time, adjusted SL#1 to breakeven level.
    • As times goes by, buy entry condition turned to sell, NT close all/or partial open position, then initiate the opposite direction trading stragtegy.


    I understand that we can use exitlongstop method, and we have BarsSinceEntry, but how can we pull out the last entry price/qty information?



    Thanks!!

    #2
    track them with Iorder

    Comment


      #3
      Originally posted by chancehero View Post
      track them with Iorder
      thx chancehero! I'll take a look. is there any sample reference codes?

      Comment


        #4
        Kevin, thanks for the kinds words - appreciated! You can check into this sample here, it shows the more advanced order management approach using event driven updates and the IOrder objects exposed - http://www.ninjatrader.com/support/f...ead.php?t=7499

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Kevin, thanks for the kinds words - appreciated! You can check into this sample here, it shows the more advanced order management approach using event driven updates and the IOrder objects exposed - http://www.ninjatrader.com/support/f...ead.php?t=7499
          thank you very much bertrand!
          I actually downloaded this before u post but still don't understand
          here is my problem:
          Code:
           
          {
              /* The entryOrder object will take on a unique ID from our EnterLong()
              that we can use later for order identification purposes in the OnOrderUpdate() method. */
              entryOrder = EnterLong(1, "MyEntry");
          /* To test, I followed Josh's way by putting:  Print( "Order Entered and OrderID is "+entryOrder.OrderID) 
          nothing happened. I even put just "Order Entered" and nothing showed up in output window. So what's wrong? */
             }
          And here:
          Code:
           
          if (stopOrder != null && stopOrder.StopPrice < Position.AvgPrice)
          //at current stage, what's the value stored in stopOrder.StopPrice? Is it the initial value say "0" or something else? I don't see this value defined anywhere in the code.
           
              {
               // Modifies stop-loss to breakeven
               stopOrder = ExitLongStop(0, true, stopOrder.Quantity, Position.AvgPrice, "MyStop", "MyEntry");
           
          // here, instead of Position.AvgPrice, is it possible to change it to the last entry order price in case we scale in? If so, I'm guessing is it execution.Order.avgFillPrice or something else?
              }
          In the code, it mentioned that:
          Code:
              /* The entryOrder object will take on a unique ID from our EnterLong()
          that we can use later for order identification purposes in the OnOrderUpdate() method. */
          what's that ID? I don't understand. Is it just "MyEntry" or some automatically generated sequential PrimaryKey or broker assigned orderID? how do we access that ID?

          And for the trigger if condition, how can we add something like:
          Code:
           
           if(entryOrder == null && CrossAbove(EMA(Fast),EMA(Slow),1)
          && Close[0] > LastEntryOrder's Entry Price + 10 ticks
          //to let strategy space out entries )
          Thanks!!




          Thank you so much!
          Last edited by kelvin2088; 02-12-2013, 12:58 AM.

          Comment


            #6
            Kevin, the MyEntry is a signal name that you assign -

            entryOrder = EnterLong(1, "MyEntry");

            This would create an entry long with a market order of quantity 1 with a signal name MyEntry. The IOrder object holding the properties would be entryOrder.

            Those properties here could be accessed -



            You can for example store the last order signal price (for example the bar close that generated the order) once you submit it with your entry condition. Some pseudo code for structure below, priceToTrack would be a double variable here.

            if (myEntryCondition)
            EnterLong()
            priceToTrack = Close[0]; // can be another price point of course as well

            Another, yet more involved coding option would be accessing the TradeCollection of the script - http://www.ninjatrader.com/support/h.../nt7/trade.htm

            Comment


              #7
              Thank you very much Bertrand!
              I'll take a look!
              So sleepy now, good night!


              Originally posted by NinjaTrader_Bertrand View Post
              Kevin, the MyEntry is a signal name that you assign -

              entryOrder = EnterLong(1, "MyEntry");

              This would create an entry long with a market order of quantity 1 with a signal name MyEntry. The IOrder object holding the properties would be entryOrder.

              Those properties here could be accessed -



              You can for example store the last order signal price (for example the bar close that generated the order) once you submit it with your entry condition. Some pseudo code for structure below, priceToTrack would be a double variable here.

              if (myEntryCondition)
              EnterLong()
              priceToTrack = Close[0]; // can be another price point of course as well

              Another, yet more involved coding option would be accessing the TradeCollection of the script - http://www.ninjatrader.com/support/h.../nt7/trade.htm

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              633 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              364 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              105 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              567 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              568 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X