Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reference Entry Price

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

    #16
    It's no fun running into a dead end. When that happens, it's best to comment out any code you don't understand, and work from a simplified point until things make sense again. Only add additional complexity once the simple stuff works.

    Whenever you're working with a new concept, try to isolate the new part from any existing code, so you can more easily follow its behavior. With OnExecution(), this means maybe just a simple example printing its events without any other complicated order condition logic. It's difficult to create all parts of your strategy all at once, especially if you're working in new territory. It's really a methodical process where you are checking one thing at a time, confirming behavior, and only then adding additional items/complexity to it.

    You can always work with one of our 3rd party consultants if you have an idea but necessarily the time or programming experience to work through these items.
    Ryan M.NinjaTrader Customer Service

    Comment


      #17
      I believe I have narrowed it down to my stoploss and profittaker being cancelled after the day of entry. Do I need to adjust the time in force on these orders? I thought that they automatically are GTC until filled, no? In my trace or orders it shows GTC, Oco. Not sure what functions in NT I would use to fix this issue myself. Thank you. Here is the lines from the output window that I am dealing with. Note the final two orders showing cancellation due to expiration.

      3/7/2005 11:00:00 PM Entered internal PlaceOrder() method at 3/7/2005 11:00:00 PM: BarsInProgress=0 Action=Buy OrderType=Limit Quantity=10 LimitPrice=32.68 StopPrice=0 SignalName='LongPosition1' FromEntrySignal=''

      3/7/2005 11:00:00 PM Entered internal PlaceOrder() method at 3/7/2005 11:00:00 PM: BarsInProgress=0 Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=31.01 SignalName='MyStopLoss' FromEntrySignal='LongPosition1'

      3/7/2005 11:00:00 PM Entered internal PlaceOrder() method at 3/7/2005 11:00:00 PM: BarsInProgress=0 Action=Sell OrderType=Stop Quantity=0 LimitPrice=0 StopPrice=30.21 SignalName='MyProfitTaker' FromEntrySignal='LongPosition1'

      3/8/2005 11:00:00 PM Cancelled expired order: BarsInProgress=0: Order='NT-00001/Sim101' Name='MyStopLoss' State=Working Instrument='BBG' Action=Sell Limit price=0 Stop price=31.0091988963162 Quantity=0 Strategy='NTDonchianTurtleSystem' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='7ea95b57c9894d8b959675bd7fa03c0e' Gtd='12/1/2099 12:00:00 AM'

      3/8/2005 11:00:00 PM Cancelled expired order: BarsInProgress=0: Order='NT-00002/Sim101' Name='MyProfitTaker' State=Working Instrument='BBG' Action=Sell Limit price=0 Stop price=30.21 Quantity=0 Strategy='NTDonchianTurtleSystem' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='45b59c11a5294f43aed5e7d12beed750' Gtd='12/1/2099 12:00:00 AM'
      Last edited by cfree5119; 02-27-2012, 09:56 AM.

      Comment


        #18
        This isn't related to the orders TIF setting, but whether they are submitted with liveUntilCancelled = true or not.

        By default orders will cancel if not filled on the bar they're submitted to. To change this, use the advanced overload and specify liveUntilCancelled = true. Below is this overload for ExitLongLimit().
        ExitLongLimit(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double limitPrice, string signalName, string fromEntrySignal)
        Ryan M.NinjaTrader Customer Service

        Comment


          #19
          Ahhh perfect. So I can submit the order under OnExecution() and then if I adjust the given stop accordingly under OnBarUpdate() into some form of a trailing stop it will stay live? Glad I finally ironed this one out. Thanks Ryan.

          Comment


            #20
            Another question Ryan. If I want to access the fill price of entryOrder1, for entryOrder2, I will not want to reset it to null, correct? This is under OnExecution().

            Comment


              #21
              Maybe a better question is, at what point will I want to reset it since I am using it for entryOrder2? See my code below.
              Last edited by cfree5119; 02-28-2012, 10:50 AM.

              Comment


                #22
                Generally you reset to null when it reaches a terminal state: filled or cancelled. The order object has served its purpose and then resetting to null allows it to be ready for the next occurrence.

                Within the same code block that resets to null, store any properties you may need (like execution price) from the order into your own variables. That way you can still have access the values you need, but you aren't holding on to your order reference longer than is needed.
                Last edited by NinjaTrader_RyanM1; 02-28-2012, 10:10 AM.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #23
                  I have another question. I receiving the below message in my output window. However, my code under Initialize() is

                  8/16/2002 3:00:00 PM Ignored PlaceOrder() method at 8/16/2002 3:00:00 PM: Action=Buy OrderType=Limit Quantity=250 LimitPrice=16.10 StopPrice=0 SignalName='LongPosition1' FromEntrySignal='' Reason='Exceeded entry signals limit based on EntryHandling and EntriesPerDirection properties'

                  Code:
                  			EntriesPerDirection		 	= 2; 
                      		EntryHandling 				= EntryHandling.UniqueEntries;
                  What else can cause this error? I am working on the second entry with IOrder objects where my entryOrder2 is submitted under OnBarUpdate() once a given condition is met. Both orders have the same signal name "LongPosition1."

                  Comment


                    #24
                    With those settings, the message suggests that you already have two open entries per uniquely named rule. It could be submitting the first two orders received and not necessarily entry1 and entry2.

                    If you want to enforce that both of your unique orders are able to be submitted, change entries per direction = 1, keep entry handling on unique entries, and provide a unique name for each of the signals.
                    Ryan M.NinjaTrader Customer Service

                    Comment


                      #25
                      Is there a way to arrange these settings so that I can have just one entrySignalName per entryOrder1 and entryOrder2 names "LongPosition1?" Reason being, I have only two stops that reference the entrySignalName to close the entire position but I use signal names on the stops in order to dynamically change them.
                      Last edited by cfree5119; 02-28-2012, 12:36 PM.

                      Comment


                        #26
                        You can set them anyway you like for the design of your strategy. If you want a stop order to apply to the whole position, place "" in the fromEntrySignal parameter for it.

                        See the following links for more information on these properties:

                        Last edited by NinjaTrader_RyanM1; 02-28-2012, 01:21 PM.
                        Ryan M.NinjaTrader Customer Service

                        Comment


                          #27
                          Thank you Ryan. I did not know the "" trick for exiting an entire position.

                          I am aware you can add another data series into a script. I am currently using daily bars and would like to keep that way. For my second entry, I would like to refer to the last price of an instrument to trigger my entryOrder2. So if close[0] >= x, then trigger my limit price at that exact price. However, sometimes when the condition is met the instrument's price will only go further up and never hit my limit price of my order because the close is so much greater than the actual last price of the instrument. As a result, I need to use a finer data series to get the actual last price instead of the close on the daily bars. Is there a sample that shows how to do this? I found some info in the tutorials.

                          Would this be the correct solution to my problem?
                          Last edited by cfree5119; 02-29-2012, 08:08 AM.

                          Comment


                            #28
                            Adding another series isn't the best way to get last price.

                            For any interval: Last price (in real time) is Close[0] when CalculateOnBarClose = false. Setting that for your strategy could work.

                            If your strategy requires COBC = true, consider getting last price from OnMarketData() event
                            Ryan M.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            629 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
                            564 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