Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unmanged Ordering not working??

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

    Unmanged Ordering not working??

    All,

    I have what I would think should be a relatively uncomplicated strategy. I buy a stock, then when I sell that stock, I buy another stock, then when I sell that second stock, I buy back the first stock. Of course, the circumstances that trigger the sells vary but for the purposes of my problem, I think this is all you need to know.

    Here's the code (in essence):

    //(at the beginning of the session)
    ioEntryOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Market, intNumShares, 0, 0, "", "Stock1");

    //(when the exit trigger is met)
    ioExitOrder = SubmitOrder(0, OrderAction.Sell, OrderType.Market, intNumShares, 0, 0, "", "Stock1");

    //(when the exit order is filled and ioExitOrder is null)
    ioEntryOrder = SubmitOrder(1, OrderAction.Buy, OrderType.Market, intNumShares, 0, 0, "", "Stock2");

    //(when the exit trigger is met)
    ioExitOrder = SubmitOrder(1, OrderAction.Sell, OrderType.Market, intNumShares, 0, 0, "", "Stock2");

    //(when the exit order is filled and ioExitOrder is null)
    ioEntryOrder = SubmitOrder(0, OrderAction.Buy, OrderType.Market, intNumShares, 0, 0, "", "Stock1");


    Rinse, Repeat, etc. Pretty straightforward, right?

    But here's the kicker - the ioEntryOrder for the second stock *frequently* results in a *BuyToCover* order. This makes absolutely no sense to me - the code *explicitly* calls for an OrderAction of "Buy" whereas "BuyToCover" is nowhere in sight in my code.

    I also don't see how this a position vs. strategy synchronization issue. After all, I don't hold anything (long OR short) in Stock 2 at the time the second ioEntryOrder takes place, so I'm not sure why NinjaTrader assumes what my position is before placing the order. Wasn't the major benefit behind unmanaged orders supposed to allow us to completely ignore the position/strategy synchronization differences in the first place?

    It's always frustrating to turn on live a strategy, which has had *no* problems in backtesting, only to come home and find out that it decided to do something completely unexpected and break as a result.

    Any help here would be appreciated. Thanks!
    Last edited by saltboy; 08-28-2012, 10:08 PM. Reason: spelling

    #2
    What has happened in market replay?

    Comment


      #3
      Hello,

      Using the unmanged orders, you can still run into a situation where the account and position is out of sync. This type of order method was not designed to ignore the position/strategy synchronization, but to ignore the NinjaTrader order handling rules and signal tracking (entries per direction, etc)

      However, based on the code you provided, I do not see where you are entering a short position in which a buytocover would be initiated.

      To troubleshoot this further, can you please run this and check for your strategy position and ensure that there is not a case where you're entering a short position?

      You can also add TraceOrders = true to your Initialize() method and you can then view valuable output related to strategy submitted orders through Tools > Output window - TraceOrders

      If you can provide us with a sample script which also demonstrates this behavior, I'd be happy to have a run at it here to help troubleshoot what you're reporting.
      MatthewNinjaTrader Product Management

      Comment


        #4
        Hi everyone - it seems that flattening everything seemed to do the trick. Not sure why, but hey, it works now! :-)

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by andrewtrades, Today, 04:57 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by chbruno, Today, 04:10 PM
        0 responses
        6 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by josh18955, 03-25-2023, 11:16 AM
        6 responses
        436 views
        0 likes
        Last Post Delerium  
        Started by FAQtrader, Today, 03:35 PM
        0 responses
        9 views
        0 likes
        Last Post FAQtrader  
        Started by rocketman7, Today, 09:41 AM
        5 responses
        20 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X