PDA

View Full Version : When using order.Filled, the program will not work


atrader
09-18-2009, 12:23 PM
because the program could not get this information in historical data. Is this a known issue? Or I was wrong.

My program was working pretty good. However, I would add some code to make sure that the previous order is fully filled, and then submit new order. However, the program stop some where, and I believe it is because it could not get the right number for order.Filled in historical data. How should I deal with this issue?

NinjaTrader_Josh
09-18-2009, 01:16 PM
Working with IOrders works regardless of real-time data or historical data. You will have to track down what is breaking your strategy logic through debugging.

atrader
09-18-2009, 01:26 PM
deal with the code, such as "if (order.Filled == intTradedShares)" in historical data? My code does not allow any further trading if the previous order is not fully filled. So if there is no way to deal with this in historical data, my program will stuck in the first trade in historical data. That is what happened to me right now. Thanks again!

NinjaTrader_Josh
09-18-2009, 01:53 PM
You can't just do order.Filled == something. You need to actually check that order is not null first. A check like that is just like any other comparison between double values provided it can access order.

http://www.ninjatrader-support2.com/vb/showthread.php?t=4226

atrader
09-18-2009, 03:24 PM
Thanks, Josh. I did it just like you suggeted. I checked the order is not null, and I assigned the order.Filled to an integer variable, then I compared if the integer variable equals to the shared the original order sent. My questions is that what ninjatrader deals with the order.Filled for historical data? i.e. what does order.Filled return when using historical data?

NinjaTrader_Josh
09-18-2009, 03:37 PM
Unfortunately not following you at all.

order is whatever you set it to be. There is no "order" unless you set this to take on some IOrder which has made some trade.

atrader
09-19-2009, 03:16 PM
Thanks, Josh. I debuged it using print command. The order.Filled returns 0 for historical data. So my code will never go further because it means that my initial order has never been filled, and no more order will be submitted if the initial order is still pending. I will find a way to deal with this issue. If you can give me a simple hint to make it a easy fix, it will be great.

NinjaTrader_Austin
09-20-2009, 02:54 PM
atrader, maybe you could post the complete code? Are you checking order.Filled in OnOrderUpdate()?

If you give us a little more information we'll probably be able to help you better.

atrader
09-21-2009, 07:54 AM
Thanks, Austin. I debugged it over the weekend. I got the order.Filled from OnOrderUpdate. It returns 0 when running through historical data. And when it is 0, it means my order will never been filled. And it stucks there forever. However, after I fixed this problem. More problems happened, and I made a new post.

NinjaTrader_Josh
09-21-2009, 08:10 AM
order.Filled will return 0 if your IOrder has never filled. It does NOT mean anything about whether or not your order will fill in the future.