Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Is it a bug

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

    #16
    Hello,

    I am looking into your sample now. I had to commend out SeesionBegin and SessionEnd DateTimes variables to compile as I was getting a compiler error in order to compile the code, do you have the same error on your side?

    I look forward to assisting you further.
    BrettNinjaTrader Product Management

    Comment


      #17
      Hi Brett,
      Do you realy believe I would send you code without trying it?
      The answer is I can and did compile it and test it.
      So after reparing my code did you run it? Try on small time frame on any instrument.

      Baruch
      p.s.
      All my strategies (more then 100) have this code.

      Comment


        #18
        Do you try it in NT6.5 not 7.
        In 7 indeed you have to comment it, but as I explained I can't use 7.

        Baruch

        Comment


          #19
          Hi Brett,
          Was you able to compile the strategy without any change or do I need an emergency course on how to write strategies.

          Baruch
          p.s.
          To see the bug takes no more then 5 seconds. If you have difficulty to see it I can assist you. Its the least I can do after you taught me how to copy/paste.

          Comment


            #20
            Hello,

            I'm having my product manager look into. I originally had loaded it into NinjaTrader 7 as I didnt recall this was a 6.5 issue. I have loaded into 6.5 and I am seeing some possible irregularities I would like to discuss with my product manager.

            Thanks for your patience.
            BrettNinjaTrader Product Management

            Comment


              #21
              Baruch,

              There is no bug here. This is a result of improper logic in the strategy. Please consider this line:

              if (!Historical || ShowBug)

              This line says to allow for trades in real-time only OR when ShowBug = true. When you add your strategy with default settings you have ShowBug = true which means the strategy does not care about this Historical check at all. It will allow for historical trades. This then means when you use "Wait until flat" your strategy will not trade live until after it reaches/crosses a flat state. Since your strategy already was trading historically, it is already in a strategy position as you start up the strategy. Holding a strategy position means you are not flat which means you will not trade live till that strategy position becomes flat.

              When you now use ShowBug = false your code check prevents all historical trades and you are never in a strategy position on strategy start up. This is why the strategy immediately trades right as the strategy starts up.

              Everything here is working correctly the way it should based on your code check.
              Josh P.NinjaTrader Customer Service

              Comment


                #22
                Josh,
                You are terribly wrong!
                Do you understand the difference between pending order and open position?
                I added this trick "if (!Historical || ShowBug)" just to make it easier for you to identify the bug. If you don't understand that, just remove the "if". Then it will always behave with a B U G.
                Again the bug is this: Although at the time you switch from historical to live you are not in a position, I repeat not in a position, in other words you are flat!! there is a pending order and NT is not able to change this order to a live order. I think that a live order gets a new ticket and this is not done.

                Baruch
                p.s.
                Why are you insist on torturing me and not concentrate on fixing a major bug?

                Comment


                  #23
                  By the way I just tested it in NT7.
                  Same bug!!
                  The only difference is that in strategies tab the strategy is colored yellow, when in 6.5 it is in green

                  Baruch

                  Comment


                    #24
                    Hi Josh,
                    I corrected the strategy.
                    Removed "ShowBug" - now you see the bug always.
                    Changed the entry price. Previously forgot to multiply by TickSize.

                    Baruch

                    The bug is still the same!
                    Attached Files

                    Comment


                      #25
                      Baruch,

                      There is absolutely no bug here and this is behaving exactly the way it should for both NT6.5 and NT7. Your expectation of using "Wait until flat" is simply incorrect. There is no concept of submitting working historical orders to be live orders when using "Wait until flat". If you wanted the historical order to be submitted as a live order you should be using the explicit option stated for this exact purpose. You should be using "Immediately submit live working historical orders".

                      "Wait until flat before executing live" means the next strategy action after starting the strategy and it reaching/crossing a flat state will be a live action. "Wait until flat" does not mean just because you are already flat you will start submitting historical actions as live actions.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #26
                        Josh,
                        "Wait antil flat" should mean that if the strategy is going from historical to live and it is in a trade then the actual trading will wait until this trade is closed and only then start a live trade.
                        But if going from historical to live there is a renewing order (issued on each bar) but the position is FLAT, why does the order from the first live bar not executed?
                        There is no concept of submitting working historical orders to be live orders when using "Wait until flat".
                        I dont want that historical order to be submited live. Again on each bar I resubmit an order. Why it is ignored?
                        Also why I can't remove a historical order?
                        I tryed:
                        private bool isHistorical = true;

                        if (isHistorical && !Historical && entryOrder != null)
                        {
                        CancelOrder(entryOrder);
                        isHistorical = false;
                        return;
                        }

                        I added the return to give ninja time to cancel the order.
                        Then on the next bar I submit NEW order. This is the code in */ ..... */. This doesn't work too.
                        You see I don't won't to submit live order if in transition from historic to live the strategy is in POSITION, but I do want to submit an order if its not in position.

                        Baruch

                        Comment


                          #27
                          Baruch,

                          If you want to have the historical order become live on strategy start you need to select "Immediately submit". That is exactly what that option is for. The option you are selecting is not for making historical orders become live orders. If you only want historical orders become live if the strategy is in a flat state, you need to program your logic in a fashion that accommodates this.

                          Renewing an order is not the same as submitting an order. On every single bar all your code is currently doing is keeping the historical order alive. That is not to say resubmit it in any sense. All you are doing on every single bar is preventing the order from expiring. Its status of a historical order does not change to a live order just because it did not expire.

                          Going "return" is not sufficient for having an order be cancelled. An order is only cancelled when you receive such an event in the OnOrderUpdate() method.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #28
                            Josh,
                            Doesn't "Immediately submit" will also submit a live order if the strategy is already in a position?
                            Going "return" is not sufficient for having an order be canceled. An order is only cancelled when you receive such an event in the OnOrderUpdate() method.
                            I'm not just executing "return". Before it I put a CancelOrder.
                            Do you want to say that on 1 min chart NT will not complete the cancellation in a whole minute? Remember we are live at this point.

                            Conclusion: NT doesn't have "Wait until flat", but rather "Wait until flat if in a position or enter and exit a trade if there is a pending order"

                            Baruch

                            Comment


                              #29
                              Baruch,

                              Yes, "Immediately submit" submits live any working order regardless of what the current strategy position is.

                              Yes, you are using CancelOrder() which is the only way to cancel an order, but simply calling CancelOrder() does not guarantee a cancel is my point. NT does not have any say on when or how fast an order takes to cancel. This is all handled by the brokerage. If they can give you a cancel state fast, you will get it fast. If they can't get it to you or can't cancel the order, then that is a completely different scenario. What I am trying to say is calling CancelOrder() and then just returning is insufficient for determining that an order was cancelled or not. The event that should be used to detect an order cancellation is OnOrderUpdate() when you receive the OrderState.Cancelled event for that order. Anything before receiving this event = the order has not been cancelled.
                              Josh P.NinjaTrader Customer Service

                              Comment


                                #30
                                Josh,
                                Again I'm sorry to tell you that your explanation is pure bull***t.
                                The order I'm trying to cancel is a virtual order on historical data. Exactly which brokerage is dealing with it? Does NT opened a brokerage and I don't know about it?
                                Don't you see the difference between joining a trade that started virtually some time ago and is now many points from the trigger and joining a trade that did not happen jet and can be entered at the entry price?
                                So because NT doesn't have pure "Wait until F L A T", but only together with "Wait until there are no active orders", how do I create this behavior? I don't know if you can think like a trader, but don't you think its a big difference btw the two?

                                Baruch

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                650 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                370 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                109 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                574 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                577 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X