Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Order Handling & Parameters

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

    #16
    additionally, I have setup a BREADCRUMB debug tracking system to trace my variables. This is the output of the script in the OUTPUT WINDOW.

    PHP Code:
    Running Pattern Code 844 0 0
    11
    /20/2012 10:12:00 AM Bullish Trigger Found -0.0025390625 :: -0.742286396026611
    Execution
    ='07691ff27caf46cab121c3d15f091cf1' Instrument='NQ 12-12' Account='Sim101' Name='Long Hammer Low Limit' Exchange=Default Price=2575 Quantity=1 Market position=Long Commission=0 Order='eda880d6ebe44e76962605220170fac2' Time='11/20/2012 10:12:00 AM'
    **NT** Strategy 'CandleScalperV1/7184306c9a3d45cba6efb73191c174bb' lost price connection but will keep running.
    Running Pattern Code 845 0 1
    **NT** Strategy 'CandleScalperV1/7184306c9a3d45cba6efb73191c174bb' lost order connection but will keep running.
    **
    NT** Strategy 'CandleScalperV1/7184306c9a3d45cba6efb73191c174bb' lost price connection but will keep running.
    Running Pattern Code 846 0 1
    Execution
    ='8ff7002a223843babdd6b99a19ef16a9' Instrument='NQ 12-12' Account='Sim101' Name='JSTarget' Exchange=Default Price=2578.25 Quantity=1 Market position=Short Commission=0 Order='9c5e2c931f0743baa11010c4abcd3cc5' Time='11/20/2012 10:18:36 AM'
    Running Pattern Code 847 0 0
    **NT** Error on calling 'OnBarUpdate' method for strategy 'CandleScalperV1/7184306c9a3d45cba6efb73191c174bb'Object reference not set to an instance of an object
    The "Running Pattern Code ### # #" values are as follows.
    CurretBar, PendingEntryDirection, EntryDirection

    PendingEntryDirection and EntryDirection are -1 for short, 0 for flat and 1 for long

    What I'm trying to figure out is why OnBarUpdate throws an error? I have an "if" statement encompassing all of the code within that event to only check for the new triggers ONCE PER NEW BAR. So something odd must be throwing that type of error ??

    Check the second chart out. After the code completed the trade and dropped the OnBarUpdate error, the chart goes back to normal.
    Attached Files

    Comment


      #17
      Hello Bmatheny,
      To assist you further can you confirm are you using the compatible version of TWS (927.7) or not.
      You can get the information from in TWS menu bar goto Help>About Traders Work Station.

      I look forward to assisting you further.
      Attached Files
      JoydeepNinjaTrader Customer Service

      Comment


        #18
        I downloaded the latest version. 932.4 Nov 1, 2012

        Comment


          #19
          OK. here is the sample script for you to review. I've removed many of the trigger conditions, but the rest of it is in place for you to see what I'm trying to accomplish.

          If you have any questions, let me know?
          Attached Files

          Comment


            #20
            Hello Bmatheny,
            Please make sure you are using TWS version 927.7. You can download TWS version 927.7 from here http://www.ninjatrader.com/ninjatrad...tall_927_7.exe

            Once you have the compatible version installed, you need to make an account connection in NinjaTrader and configure TWS. To do it please follow the steps as mentioned here


            Please let me know if I can assist you any further.
            JoydeepNinjaTrader Customer Service

            Comment


              #21
              trying it now..

              Comment


                #22
                Very odd things happening this AM.

                PHP Code:
                Running Pattern Code 1244 0 0
                Running Pattern Code 1245 0 0
                11
                /21/2012 7:15:00 AM Bearish Trigger Found -2.201171875 :: -0.99790096282959
                Execution
                ='1e7327fde5c34688a6de474765d456d6' Instrument='NQ 12-12' Account='Sim101' Name='Short Hammer High Limit' Exchange=Default Price=2592.5 Quantity=1 Market position=Short Commission=0 Order='9314845303ac4a77b5969a9c5aa5ff2b' Time='11/21/2012 7:15:20 AM'
                Running Pattern Code 1246 0 -1
                11
                /21/2012 7:18:00 AM Bullish Trigger Found 0.2923828125 :: 0.304195499420166
                **NT** An Enter() method to submit an entry order at '11/21/2012 7:21:00 AM' has been ignoredPlease search on the term 'Internal Order Handling Rules' in the Help Guide for detailed explanation.
                Running Pattern Code 1247 1 -1
                **NT** Error on calling 'OnBarUpdate' method for strategy 'CandleScalperV1/8485f88a053d45649ee2e96c9c26e887'Object reference not set to an instance of an object
                Why in the world would it enter a short trigger, then fall back into the condition for checking a short trigger again and generate an error on "Enter()"??

                This is a reversal system, so it should be able to handle reversing an order - right?

                boy would I like to know why this is happening.

                Comment


                  #23
                  I've come to the conclusion that the is probably something wrong with the IOrder feature and/or the way I'm using it.

                  I setup my code to be able to reuse the IOrder structure for each entry. do the need to be re instantiated with each new entry?

                  I've changed my code so that it can't be a reversal system any longer to see if it act any differently.

                  I have to say, it sure would be nice to have a strategy developers guide for simple items like this. How to build a reversal system and how to handle multiple triggers/orders.

                  Hope to hear from you soon.

                  Comment


                    #24
                    Hello
                    The internal order handling rules of the managed approach is ignoring your entry order.

                    Please set TraceOrder to true to know the exact reason for the order rejections.

                    If you are using the same code as attached, then you are probably facing the following scenario:
                    A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction
                    JoydeepNinjaTrader Customer Service

                    Comment


                      #25
                      Let's do this. The examples for IOrder are very limited. I would like to ask for some basic instructions of using the IOrder feature.

                      Imagine this..

                      I am building a reversal system that fires two entry orders. One above the last bar's close and one above the last bar's close. Which ever order gets filled first, I want to cancel the other and then fire two orders (a stop and a target) to handle the active trade.

                      I want the system to be able to reverse under the same conditions, so if it fires a short trade last bar and is now setup for a long trade, I want the two LONG entry orders to be fired and reverse the position if one gets filled.

                      While trying to initiate the long order, I want the SHORT target and stop to continue working.

                      I setup four IOrder variable to handle the trading needs of my robot (one for each order). I believe the problem I'm having that these IOrder values are not being handed properly.

                      How do I reset an IOrder variable after a trade completes?
                      How do I initiate a new set of orders for a new potential entry position?
                      Is there any more detailed examples of a complex reversal system like I've described?

                      Comment


                        #26
                        Once I removed the Reversal portion of my code, the entire thing is running better. Is there something I'm missing or s NT not able to handle reversal orders very well?

                        Comment


                          #27
                          Originally posted by Bmatheny View Post
                          I am building a reversal system that fires two entry orders. One above the last bar's close and one above the last bar's close.
                          Hello,
                          Can you please further clarify the above.

                          Are you trying to place a bracket order (buy and sell order at the same time?)

                          I look forward to assisting you further.
                          JoydeepNinjaTrader Customer Service

                          Comment


                            #28
                            No. Here is an example of a long entry order...

                            Place a BUY STOP order 2 ticks above the high of the last bar
                            Place a BUY LIMIT order 2 ticks above the low of the last bar.

                            This way, I either get filled on a runner or a pullback. Of course, the pullback (low) order would be a better price fill, but this type of order system is designed to provide a method of entry that allows for variant price activity.

                            Comment


                              #29
                              looks like I get to rewrite my strategy some more. lol

                              Comment


                                #30
                                Hello Bmatheny,
                                Thanks for the clarification.

                                You can use the Managed approach however you have to set appropriate Entry Handling to do it. If one order get filled then you have to cancel the other order using the CancelOrder method.



                                Alternatively you can use the Unmanaged approach to do it, where you can OCO out the orders (if stop gets filled limit order will get cancelled automatically).
                                JoydeepNinjaTrader Customer Service

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Jimmyk, 01-26-2018, 05:19 AM
                                6 responses
                                835 views
                                0 likes
                                Last Post emuns
                                by emuns
                                 
                                Started by jxs_xrj, 01-12-2020, 09:49 AM
                                6 responses
                                3,290 views
                                1 like
                                Last Post jgualdronc  
                                Started by Touch-Ups, Today, 10:36 AM
                                0 responses
                                10 views
                                0 likes
                                Last Post Touch-Ups  
                                Started by geddyisodin, 04-25-2024, 05:20 AM
                                11 responses
                                62 views
                                0 likes
                                Last Post halgo_boulder  
                                Started by Option Whisperer, Today, 09:55 AM
                                0 responses
                                8 views
                                0 likes
                                Last Post Option Whisperer  
                                Working...
                                X