PDA

View Full Version : Method to ensure limit fill on ATM strategy


zeller4
07-23-2010, 06:21 AM
Hello,

I'm using the SampleATMStrategy and have looked for ways to "guarantee" a fill of a limit order.

With a 50 tick chart:
When a candle "straddles" the entry price, the fill works with the first part.
However, sometimes the High[1] == entryPriceL and Low[0] == entryPriceL so those candles don't "straddle" the entry price and wouldn't necessarily give a filled condition.

I've tried using this but not sure the logic is right:

if ((High[0] > entryPriceL && Low[0] < entryPriceL)||
(High[1] >= entryPriceL && Low[1] <= entryPriceL)
)
{
longFilled = true;
}
if (longFilled)
AtmStrategyCreate(Cbi.Action.Buy, OrderType.Limit, entryPriceL, 0, TimeInForce.Day, orderId, "AtmStrategyTemplate", atmStrategyId);



Is there a better way to ensure a fill?
Thanks,
Kirk

NinjaTrader_Tim
07-23-2010, 07:21 AM
Hi zeller4,

I understand what you are trying to do, however there really is no way of guaranteeing a fill with a limit order. You can guarantee the price with a limit order, or you can guarantee a fill (in most cases) with a market order. The price can jump around, gap up or down, so in general, I cannot comment on any way to "guarantee" a limit order fill.

Buy market order: http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?EnterLong

zeller4
07-23-2010, 12:08 PM
I understand , that's why I put guarantee in "..."!

How about the use of Bid() and Ask() (with or without OnMarketData) so that if these "surround" my limit price, I can take the one that's close to the market?

Any sample code or snippets for that?

kz

NinjaTrader_Tim
07-23-2010, 12:18 PM
Hi zeller4,

You can access that with GetCurrenBid() or GetCurrentAsk() if you provider supports it.
Keep in mind this will only return the correct value in real time, live trading.

http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?GetCurrentBid
http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?GetCurrentAsk