• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

LiveUntilCancelled switch issue

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

    LiveUntilCancelled switch issue

    Hi,

    I'm developing a backtesting trading strategy with a programmed CancelOrder. I'm experiencing an issue with the following instruction:

    entryOrder = EnterLongLimit(myTimeframe,true, DefaultQuantity,orderLevel, "Long:"+myPeriodTypeLegend);

    When I turn the LiveUntilCancelled switch to true, my order entries do not appear in the graph screen. And when I turn the same switch to false, the orders appear normally.

    In the attachment, the left side graph shows the entries with the switch turned to false and the right side graph does not show the order entries when the switch is turned to true.

    How can I solve this issue?.

    Thank you.
    Attached Files
    Last edited by rperez; 11-16-2009, 08:57 PM.

    #2
    rperez, please work with TraceOrders ( http://www.ninjatrader-support2.com/...ead.php?t=3627 ) to debug why you see this behavior, with liveUntilCancelled orders you can easily run into the Internal Order Handling Rules, which would prevent entries from getting executed as one would expect -

    http://www.ninjatrader-support.com/H...verview36.html (bottom section here)
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand,

      This is a message from the output window with the liveUntilCancelled sset to false. The corresponding orders appear in the screen:

      13/11/2009 10:00:00 a.m. Entered internal PlaceOrder() method at 13/11/2009 10:00:00 a.m.: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1088,50 SignalName='MiStop' FromEntrySignal='Corto:1Min'
      13/11/2009 10:00:00 a.m. Entered internal PlaceOrder() method at 13/11/2009 10:00:00 a.m.: Action=BuyToCover OrderType=Limit Quantity=1 LimitPrice=1083,50 StopPrice=0 SignalName='MiTarget' FromEntrySignal='Corto:1Min'
      13/11/2009 10:00:00 a.m. Cancelled pending exit order, since associated position is closed: Order='NT-00050/Sim101' Name='MiStop' State=Working Instrument='ES 12-09' Action=BuyToCover Limit price=0 Stop price=1088,42638568816 Quantity=1 Strategy='IntrabarBackTest4' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='ec79754230d54817bacb3dd4d0b4c837' Gtd='01/12/2099 12:00:00 a.m.'



      And now, the same message with the switch turned to true:

      13/11/2009 10:00:00 a.m. Entered internal PlaceOrder() method at 13/11/2009 10:00:00 a.m.: Action=BuyToCover OrderType=Stop Quantity=1 LimitPrice=0 StopPrice=1088,50 SignalName='MiStop' FromEntrySignal='Corto:1Min'
      13/11/2009 10:00:00 a.m. Entered internal PlaceOrder() method at 13/11/2009 10:00:00 a.m.: Action=BuyToCover OrderType=Limit Quantity=1 LimitPrice=1083,50 StopPrice=0 SignalName='MiTarget' FromEntrySignal='Corto:1Min'
      13/11/2009 10:00:00 a.m. Cancelled pending exit order, since associated position is closed: Order='NT-00063/Sim101' Name='MiStop' State=Working Instrument='ES 12-09' Action=BuyToCover Limit price=0 Stop price=1088,42638568816 Quantity=1 Strategy='IntrabarBackTest4' Type=Stop Tif=Gtc Oco='' Filled=0 Fill price=0 Token='e4422b1f3b3647eb95ebcb6b061bc792' Gtd='01/12/2099 12:00:00 a.m.'


      As you can see, they are basically the same, but the orders DO NOT appear in the screen.

      Any idea?

      Comment


        #4
        rperez,

        These are not the traces for the order in the code snippet you provided earlier. Please find the trace output in relation to the entry order as opposed to the stop/target exit orders.

        Suggest you also check the Control Center logs for any runtime errors.
        JoshNinjaTrader Customer Service

        Comment


          #5
          Thanks again Bertrand,

          I think I found the cause of the problem because it appears to be working fine now.

          I had forgotten to store the result of the following instruction in the entryOrder variable:

          entryOrder = ExitShort(myTimeframe,DefaultQuantity,"CubreCorto" , "Corto:"+ myPeriodValue);

          I had it as:

          ExitShort(myTimeframe,DefaultQuantity,"CubreCorto" , "Corto:"+ myPeriodValue);


          Does it make any sense?

          Comment


            #6
            Sorry I don't really follow, but glad to hear you're back to working state.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Bertrand,

              Unfortunatelly, when backtesting my program, the lower time frame doesn't seem to be working, and neither does my liveUntilCancelled switch allow the viewing of any entries . I've assembled my program from the Sampleprograms found on this forum, so you will find everything is familiar. I've simplified it to leave only the assembled pieces from the sample programs.

              Would you mind if I ask you to please take a fast look at the program to see if you find any obvious mistakes? I am not a very experienced programmer.

              Thank you.
              Attached Files
              Last edited by rperez; 11-17-2009, 08:16 PM.

              Comment


                #8
                Yours wouldn't even compile on my end, fixed two errors and ran it, displayed trades and placed orders as expected for me - please recheck the attached, thanks.
                Attached Files
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Hi Bertrand,

                  Thank you very much for your kind support.

                  Did you try to run a backtest with the 1 min smaller time frame by setting myTimeFrame to 1? It doesn`t generate any orders.

                  And when the MyliveUntilCancelled switch is turned to true, no orders show up either.

                  Those are the two main problems the program seems to have.
                  Attached Files
                  Last edited by rperez; 11-18-2009, 08:04 AM.

                  Comment


                    #10
                    rperez, thanks for the trace order output I believe you cancel them to early, as you basically cancel them immediately after placing them.

                    Try to simplify things in the strategy, for example leaving the stops and targets / breakeven portion out and just ensure the entries are working as you would expect with the intrabar backtesting included, then move on from there.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Good point Bertrand... I hadn't realized the orders were being cancelled immediately..... that's because of my inexperience as a programmer.... I just don't have feel for it yet.... as you obviously do! Thanks.

                      Comment


                        #12
                        Bertrand,

                        I got the program fixed and is working ok with minute bars. But, when trying to load my strategy or any other strategy, including the Sample Intrabar Strategy, with Range bars as the primary TimeFrame, the Strategy Analyzer generates an error.

                        My computer has 2 Gigs of memory, so it is not due to lack of computer resources.

                        Is there some specific and known issue regarding Ninja handling Range bars?

                        Thanks.
                        Attached Files
                        Last edited by rperez; 11-18-2009, 03:50 PM.

                        Comment


                          #13
                          rperez,

                          2 gigs of RAM is not that much RAM especially when running extended backtests on tick based intervals. Range charts are tick based. Please decrease your backtest time range.
                          JoshNinjaTrader Customer Service

                          Comment


                            #14
                            Thank you Josh....

                            Do you mean to say, instead of a 12R graph, use a 2R graph?, or,
                            Instead of backtesting data for 30 days back , use only 10 days back?

                            In any case, I've tried both a neither seems to work.

                            Comment


                              #15
                              Originally posted by rperez View Post
                              Thank you Josh....

                              Do you mean to say, instead of a 12R graph, use a 2R graph?, or,
                              Instead of backtesting data for 30 days back , use only 10 days back?

                              In any case, I've tried both a neither seems to work.
                              He means instead of backtesting for 30 days back, just backtest for 10 days back.

                              Just like Josh said, range charts are built from ticks and backtesting many days worth of tick data is very computer intensive (especially if you're working with ES).

                              Can you get something like a 1 or 2 day backtest to work?
                              AustinNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by lomaduza, Today, 11:46 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post lomaduza  
                              Started by jiknonikkocv, Today, 11:23 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post jiknonikkocv  
                              Started by luxurious_04, Yesterday, 07:13 PM
                              2 responses
                              10 views
                              0 likes
                              Last Post luxurious_04  
                              Started by swcooke, Today, 07:35 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post swcooke
                              by swcooke
                               
                              Started by Miguel_88, Today, 06:41 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post Miguel_88  
                              Working...
                              X