PDA

View Full Version : Limit orders - book position kept when new orders are generated


Fabrice
07-04-2007, 03:57 AM
I would like to have some insight into the ways Ninja handles Limit orders when a limit order has been sent at a price P and a new Limit order is sent at the same price P (order not amended but a new order).

Does ninja leave the original order in the book queue (as it is the same price) and allocates that order (and therefore keep the position in the queue) to the new limit order generated or does it cancel the order in the queue and send a new order to the exchange (losing the position in the queue)?

When setting up in a strategy, CalculateOnBarClose = false in the Initiliaze function to make sure my orders are computed at each tick received (orders computed in context 0, ie BarsInProgress == 0).

I update some variables every N ticks, from those variables I generate a Limit orders at every tick. The value of the limit order only changes every N ticks but at every tick I send a new order.

Does Ninja is smart enough to recognize that a previous order was positionned in the book at a price P at the previous tick and when a new order is generated at price P at the current tick, leaves the previous order in the queue and does not in fact send a new order to the exchange. Sending a new order would lose the priority in the book ?

I read in the documentation somewhere that Ninja should behave that way but I thought I would better ask the question ...

Thanks,
Fabrice.

NinjaTrader_Dierk
07-04-2007, 04:03 AM
>> new Limit order is sent at the same price P
Not sure I follow.

Are you:
a) placing a new order based on different entry signal e.g. EnterLongLimit(price, "newSignal") OR
b) are you calling the same entry signal again e.g. EnterLongLimit(price)

On a): NT submits a new order
On b): NT will not touch the order which is already in the market provided the price did not change

Fabrice
07-04-2007, 05:50 AM
>> new Limit order is sent at the same price P
Not sure I follow.

Are you:
a) placing a new order based on different entry signal e.g. EnterLongLimit(price, "newSignal") OR
b) are you calling the same entry signal again e.g. EnterLongLimit(price)

On a): NT submits a new order
On b): NT will not touch the order which is already in the market provided the price did not change


My code:

if (BarsInProgress == 0)
{
EnterShortLimit(NumContractsToTrade, pEntryShort, "Enter Short");
EnterLongLimit(NumContractsToTrade, pEntryLong, "Enter Long");
}

at each tick but the pEntryShort and pEntryLong varies only every N ticks. The "Enter Short" and "Enter Long" never change so I presume I am in case (b) ?

So my signal name entry does not change during the N ticks duration period but that order is generated at each tick.

I am using a strategy with a target Limit order and I want my target limit order to be sent (exit my position) after N milliseconds if the market has quoted my price but my order was not filled. To be able to timestamp the first quotation at my limit price I need to track all incoming ticks and generate orders at the tick level. I just want to make sure I do not lose my position in the book.

I am not sure if there is an automated way to fire Limit orders as market order after a given number of milliseconds if my order was not filled (on a high or low of a bar for example) after the first quotation at my limit order price.

Ninja is a good product. I found few bugs here that I will document in the forum.

Thanks for your previous answer,
Fabrice.

NinjaTrader_Dierk
07-04-2007, 05:59 AM
Right, scenario (b) -> no issue

Sorry there is no support for a timer driven approach in NT. You would need to handle this by custom coding. Please contact e.g. a NinjaTrader consultant if you would need support on how to do that: http://www.ninjatrader.com/webnew/partners_onlinetrading_NinjaScript.htm

Fabrice
07-04-2007, 06:20 AM
Thanks for your reply, good.

I wrote a strategy with the approach I specified earlier. I have been following Ninja trader since the beginning, great product.

I might have found some bugs, will report them to the forum a bit later.

Thanks again,
Fabrice.

Folls
10-13-2007, 02:57 PM
Hi. Did you ever accomplish turning a limit order to a market order after a certain time period? If so, I would appreciate seeing the code. I would like to do the same thing.

Thanks,

Folls

NinjaTrader_Josh
10-13-2007, 03:16 PM
if (Close[0] > Close[1])
{
if (entryTimeSet == false)
{
enterTime = Time[0];
entryTimeSet = true;
}

if (Time[0] < enterTime.AddMinutes(10) && Position.MarketPosition == MarketPosition.Flat)
EnterLongLimit(100, "Long Limit");
else if (switchedToMarket == false && Position.MarketPosition == MarketPosition.Flat)
{
EnterLong();
switchedToMarket == true;
}

if (Position.MarketPosition == MarketPosition.Long)
{
entryTimeSet = false;
switchedToMarket == false;
}
}See if this works out for you. I haven't tested it though.