Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Any reason NT would not enter an order if conditions are met?

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

    Any reason NT would not enter an order if conditions are met?

    Hello,

    Here's a couple of things about how my NT is running.
    1. I have a NT Strategy running in real time against market data on a live account.
    2. I have NT Options set to record live data and store it.

    I did not see the bars as they were generated but, the bars should be as they were when generated during live trading because I have not "Reloaded historical data" and I have my NT set up to record live data.

    All of my conditions are met and yet an order is not called for. Is there any logical reason for this behavior. Is there a bug or something else I should know about.

    Thanks in advance for any help anyone can offer.

    dendy.

    #2
    You will want to debug your strategy. If conditions have truly been met then your strategy will place your orders. There may be reasons like reaching the maximum number of entries per direction can limit the amount of orders accepted, but other than that you will need to see your Output Window for reasons your strategy is either ignoring or simply not placing orders.

    Please see these tips: http://www.ninjatrader-support.com/v...ead.php?t=3418
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the help Josh.

      The interesting thing that I see is that when the conditions are met 3 minutes later, an order is placed. I also cannot remember ever having this problem before (I run this strategy nearly every day).

      I have debugged thoroughly before and I don't believe I have problems there. The trace orders you mentioned are interesting and I think this maybe useful. Is there any way that I could go back and tell what may have happened, or must I just try to catch this issue from this point on by always tracing my orders.

      Also, there was no order placed to enter a position. How can a trace order help with that when it traces orders, it does not trace every bar when there is no order, right?

      Is it possible that despite the way I have NT setup, my bars changed when I reopened or downloaded historical data to refill the latest part of my chart. (I know that this should not happen but I'm looking for all possible causes.)

      Thanks again.

      dendy.

      Comment


        #4
        TraceOrders will help you if you find a spot where your strategy continually does not trade. If that spot is really a spot to be traded the TraceOrders will push out a reason as to why your order was ignored/cancelled/etc.

        TraceOrders will trace whenever there is an update to an order.

        If you are not even having an order placed this is something to do with your strategy logic and not the orders. You will need to check your conditions. Print out values manually and see if that spot is actually a spot it should trade at. If NT does not place an order it means your strategy's conditions were not satisfied.

        Backtesting is never the same as real-time. If you reloaded your strategy on a chart all previous bars become historical and so it will not present possible trades as it would in real-time. Please see: http://www.ninjatrader-support.com/H...sBacktest.html
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I think I understand.

          I run backtests as well as real time trades on bar close. I realize the differences between backtest and real time bars.

          Still, if the conditions are met, trades should be called for.

          I can think of one reasonable possibility. The bars have changed somehow. I don't know how they would have changed given my setup but it appears that maybe these bars were different during live trades. I know that this data should not have been reloaded but how else could this have occurred?

          By the way, is the forum's search feature functioning properly? I get a message about a minuimum word length of 4 not being met or something to that effect.

          Thanks again.

          dendy.

          Comment


            #6
            Hello,

            I suggest using TraceOrders and Print() to dig into the issue further.


            The forum only searches for words that are larger than 3 letters long.
            DenNinjaTrader Customer Service

            Comment


              #7
              Thanks for answering the question about the forum Ben.

              Perhaps one day I'll be able to track down the origin of the issue I'm having. I don't think tracing orders or Print can help me at this point because this is not a new strategy. In fact, I have many live orders made with this strategy already. Thanks for the help.

              dendy.

              Comment


                #8
                Hello Josh,

                How would I use the drawdot function you mentioned in one of the attached posts to draw a dot for a trail stop. I could not make the DrawDot work correctly.

                Thanks,

                dendy.

                Comment


                  #9
                  You could use DrawDot() if you want. To use it you would need to follow this syntax: DrawDot(string tag, bool autoScale, int barsAgo, double y, Color color)

                  If you wish for many dots make sure your string is unique per bar.

                  Ex:
                  Code:
                  DrawDot("trail stop" + CurrentBar, false, 0, trailStopPrice, Color.Red);
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    I am having trouble with the part you call "trailstopPrice". How do I call this value from my SetTrailStop.

                    I know the value of my Trail Stop but that value is not the trail stop price.

                    Thanks.

                    dendy.

                    Comment


                      #11
                      Good question, but first, are you running with CalculateOnBarClose = false?
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        No, CalculateOnBarClose = true;.

                        Comment


                          #13
                          Josh,

                          I guess the CalculateOnBarClose makes some difference for how I would specify the "trailstopPrice". Can you explain further how this is done for DrawDot.

                          dendy.

                          Comment


                            #14
                            Hi dendy,

                            Since you are running with it being true it makes it more difficult to track. This is the case because SetTrailStop() runs tick by tick regardless of what you have CalculateOnBarClose set as. This is what you need to do:

                            1. change your strategy to use CalculateOnBarClose = false.
                            2. if you wanted your strategy on the CalculateOnBarClose = true logic, bracket your whole strategy with: if (FirstTickOfBar) { }
                            3. After you bracket everything you need to now change every single index to one back. So if you had SMA(5)[0] you need to change that to SMA(5)[1]. If you had SMA(5)[1] that needs to become SMA(5)[2].
                            4. Inside where you do EnterLong() you need to set trailStopValue. If your stop was for 10 ticks
                            5. Now, outside of the FirstTickOfBar bracket, you need to add your tracking logic. Let's say you had it set to 10 ticks.
                            PSEUDOCODE-Not Tested
                            Code:
                            // In variables section
                            private bool setTrail = true;
                            private double currentHigh = 0;
                            private double prevHigh = 0;
                            private double trailStopValue = 0;
                            
                            // In OnBarUpdate()
                            if (Position.MarketPosition == MarketPosition.Long)
                            {
                                 // Only want to set our initial trail stop tracker once
                                 if (setTrail)
                                 {
                                      trailStopValue = Position.AvgPrice;
                                      setTrail = false;
                                 }
                                 
                                 // For every new high add that value to our trailStopValue
                                 currentHigh = High[0];
                                 trailStopValue = trailStopValue + (currentHigh - prevHigh);
                                 prevHigh = currentHigh;
                            }
                            
                            if (Position.MarketPosition == MarketPosition.Flat)
                            {
                                 // Reset our trail stop tracker flag to allow for future trackings
                                 if (setTrail == false)
                                      setTrail = true;
                            }
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Thanks Josh,

                              I'm working with this.

                              dendy.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by pechtri, 06-22-2023, 02:31 AM
                              9 responses
                              122 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by frankthearm, 04-18-2024, 09:08 AM
                              16 responses
                              64 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by habeebft, Today, 01:18 PM
                              1 response
                              5 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by benmarkal, Today, 12:52 PM
                              2 responses
                              13 views
                              0 likes
                              Last Post benmarkal  
                              Started by f.saeidi, Today, 01:38 PM
                              1 response
                              7 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X