PDA

View Full Version : Backtesting - Limit Vs. Market


CashCache
08-25-2008, 09:26 PM
My strategy allows the user to select the type of target orders to use - Limit or Market orders. I find that when backtesting with Limit Orders, I get much more realistic results data than I so with Market orders. I understand the Strategy Analyzer has only 4 points of data to work with (OHLC), but the help document does not say anything (that I could find) about the type of order during the backtest.

It appears that when I backtest my strategy using market orders it uses the bar close as the fill price. When I use Limit orders, it uses the limit price as the fill price.

Is this correct?

Thanks,

-Scott

p.s. I'm using CalculateOnBarClose = false.

NinjaTrader_Josh
08-25-2008, 10:32 PM
Market Orders will be filled at the next possible price which would be the Open of the next bar.

CalculateOnBarClose has no bearing during backtesting because it is always true. You have OHLC at the end of a bar so since you have C you are at bar close.

CashCache
08-25-2008, 11:13 PM
Thanks Josh,

That's what I figured, but wanted to be sure.

Thanks,

-Scott

saltminer
10-02-2008, 08:00 PM
On this topic, the backtesting with a limit order seems not to work as I expect.
What I expect is
"Fill at the limit price or better"
but what I see happening on a backtest is
"Filled exactly at the limit price even if a better price was available" (e.g. the opening price of the new bar)

Take a look at the image example, which is a Short entry being filled with a limit order equal to the previous bar close and two ticks worse. This is the exact price that I get filled at, EVEN THOUGH the open of my fill bar is a better price. I entered this with a EnterShortLimit() order.

This is not realistic for real life. A broker would not bypass a better price in order to get the limit price. Is there a workaround, or am I missing something?
Cheers,
saltminer

NinjaTrader_Josh
10-02-2008, 08:13 PM
saltminer,

This is the case because NinjaTrader takes a conservative approach to fill logic to prevent any potential overstating of profitability. You can try switching your Fill Type to Liberal and see if it helps.