Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Market Buy VS Limit Buy at Ask

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

    Market Buy VS Limit Buy at Ask

    As I work on automated strategies I am trying to minimize the difference between back-testing, replay testing, and live or simulated results. Depending on the type of bar being used one can get amazing backtested results which virtually never translate into real results. I understand that this happens though I only partially understand why. In order to minimize this, one of the things that I do is use limit orders at bid and ask instead of market orders. For instance instead of:

    EnterLong();

    I will use:
    EnterLongLimit(DefaultQuantity, GetCurrentAsk(), "") ;

    So my question is: Is this legitimate. In terms of backtesting, can I assume that I don't have any or at least as much slippage as I would entering a market order. In my real world experience entering a buy at the ask, gets me filled immediately, at least in instruments with sufficient volume, (like the ES for instance), at a time of the day when the market is moving, (first hour or so).

    Aside from the theoretical concerns that it is possible to not get filled at the ask should price move away just before or just after entering the order, is there any other considerations that I haven't articulated.

    Basically is this a reasonable approach to minimize the theoretical slippage which always occurs in backtesting?

    Thanks

    DaveN

    #2
    Hello DaveN,
    Thanks for your post.

    Unfortunately the GetCurrentAsk is a real time property and cannot be accessed during backtesting.

    When accessed during a historical backtest, the close price of the evaluated bar is substituted.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      This is good. So in terms of backtesting there should be no difference in results for the two following actions:

      EnterLongLimit(DefaultQuantity, GetCurrentAsk(), "") ;

      or

      EnterLongLimit(DefaultQuantity,Close[0], "") ;

      Is that correct?

      In actual performance though, the limit at the ask should fill faster than the limit at the Close, depending of course on the direction, if any, that the market is moving. Is that correct?

      Thanks

      Comment


        #4
        Hello DaveN,
        Yes, correct. In backtest GetCurrentAsk and Close[0] will return the same value.

        Yes, in RT for buy orders GetCurrentAsk has better chance to get filled that Close[0].
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by tonynt, Yesterday, 01:48 PM
        2 responses
        10 views
        0 likes
        Last Post tonynt
        by tonynt
         
        Started by goodknight777, Today, 08:43 AM
        1 response
        2 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Salahinho99, 05-05-2024, 04:13 AM
        5 responses
        47 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by ttrader23, Yesterday, 09:04 AM
        7 responses
        34 views
        0 likes
        Last Post ttrader23  
        Started by damethetrader, Today, 08:31 AM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Working...
        X