Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Two Bars Needed to Reverse Direction

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

    Two Bars Needed to Reverse Direction

    NT,

    Why does there have to be two bars moving in the same direction to execute a trade in my strategy?

    The following simple code requires two bars in the reverse direction to reverse my position in a strategy. ( This shows up in backtesting also.)

    ------------------------------------------------------------

    // Condition set 1

    if (Close[1] < Close[0])
    {

    EnterLongLimit(1, GetCurrentAsk(), "");
    }
    // Condition set 2
    if (Close[1] > Close[0])
    {
    EnterShortLimit(1, GetCurrentBid(), "");

    }

    ------------------------------------------------------------

    If there is only one bar reversed, and the next bar continues in the previous direction, NT ignores the trade.

    Can you explain this. I am using Renko Bars.

    Thanks,

    RJay
    Last edited by RJay; 03-14-2009, 04:30 PM.
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    #2
    Hello,

    What is probably happening is one trade is placed and stays open. When the next one opens it cancels your existing order then reverses. This would be expected behavior since you cannot literally be long and short within the same market.
    DenNinjaTrader Customer Service

    Comment


      #3
      Every Time I open a strategy, I get the following log message.

      ------------------------------------------------------------------

      ########StrategyAn Enter() method to submit an entry order at '3/12/2009 11:40:35 PM' has been ignored. Please search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.

      ------------------------------------------------------------------

      How do I get rid of this phantom order from last week?

      Thanks,

      RJay
      RJay
      NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

      Comment


        #4
        rt6176,

        I am assuming you are running with CalculateOnBarClose = false? The issue is that you cannot have both of those orders working at the same time. You will need to cancel one before submitting the other. To cancel, please use CancelOrder().

        Josh P.NinjaTrader Customer Service

        Comment


          #5
          I have tried everything I can think of to get rid of this order.

          I have deleted my charts, strategies, logs, reset the sim101 account and the problem is still there.

          How do I cancel this order if I can't find it !!!

          Do you do a global flattening for all outstanding orders?
          RJay
          NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

          Comment


            #6
            rt6176,

            This has nothing to do with your prior orders. It occurs as you run your newest instance of your strategy. You cannot submit EnterLongLimit and EnterShortLimit at the same time. They cannot both be active. You need to use the IOrder of them to cancel one before submitting the other.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Josh View Post
              rt6176,

              This has nothing to do with your prior orders. It occurs as you run your newest instance of your strategy. You cannot submit EnterLongLimit and EnterShortLimit at the same time. They cannot both be active. You need to use the IOrder of them to cancel one before submitting the other.

              The LongLimit and ShortLimit orders have their own unique "if" statements.

              What do you suggest I do if this is wrong.

              This was built through your Strategy builder.
              RJay
              NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

              Comment


                #8
                rt6176,

                It does not matter if they are unique if-statements. What is not allowed is placement of simultaneous long limit and short limit orders. If you use CalculateOnBarClose = true this situation should not occur. If you still wnat to use it as false you will then want to split your strategy into two separate strategies, one for your longs and another for your shorts.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  I must be really stupid!

                  I just wasted 4 days trying to find a workaround.

                  Why can't there be two unique conditions each with their own market orders in a single strategy?

                  Is there any other way to enter strategy market orders where the NT won't pitch a fit?

                  Also, If I tell NT I want to only trade 1 emini at a time, why an I seeing this....


                  Action Time E/X Position Name Account
                  Buy 3/17/2009 13:53 Entry 1L Close position Sim101
                  Buy 3/17/2009 13:53 Entry 2L Buy Sim101
                  Sell 3/17/2009 13:53 Exit 1L Close position Sim101
                  Sell 3/17/2009 13:53 Exit - Sell short Sim101
                  Buy 3/17/2009 14:02 Entry 1L Close position Sim101
                  Buy 3/17/2009 14:02 Entry 2L Buy Sim101
                  Sell 3/17/2009 14:27 Exit 1L Close position Sim101
                  Sell 3/17/2009 14:27 Exit - Sell short Sim101
                  Buy 3/17/2009 14:32 Entry 1L Close position Sim101
                  Buy 3/17/2009 14:32 Entry 2L Buy Sim101
                  Sell 3/17/2009 14:32 Exit 1L Close position Sim101
                  Sell 3/17/2009 14:32 Exit - Sell short Sim101
                  Buy 3/17/2009 14:46 Entry 1L Close position Sim101
                  Buy 3/17/2009 14:46 Entry 2L Buy Sim101
                  Sell 3/17/2009 14:58 Exit 1L Close position Sim101
                  Sell 3/17/2009 14:58 Exit - Sell short Sim101
                  Sell 3/17/2009 15:54 Entry 1S Sell short Sim101
                  Buy 3/17/2009 15:57 Exit - Close position Sim101
                  Buy 3/17/2009 15:57 Entry 1L Buy Sim101
                  Sell 3/17/2009 16:00 Exit - Close position Sim101
                  Sell 3/17/2009 16:00 Entry 1S Sell short Sim101

                  RJay
                  NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                  Comment


                    #10
                    rt6176,

                    You can have them. You just cannot submit two active working limit orders in the opposite directions. I do not understand what you are printing. You will need to use TraceOrders = true. You need to use EntriesPerDirection = 1.
                    Josh P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by casabella, Today, 04:12 AM
                    0 responses
                    10 views
                    0 likes
                    Last Post casabella  
                    Started by Ludwik, Today, 03:52 AM
                    0 responses
                    7 views
                    0 likes
                    Last Post Ludwik
                    by Ludwik
                     
                    Started by wuannetraam, Today, 02:40 AM
                    0 responses
                    10 views
                    0 likes
                    Last Post wuannetraam  
                    Started by cyberpete76, 03-27-2023, 12:29 AM
                    7 responses
                    272 views
                    1 like
                    Last Post slightly  
                    Started by renewsaltwater, Today, 01:15 AM
                    0 responses
                    4 views
                    0 likes
                    Last Post renewsaltwater  
                    Working...
                    X