Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Slippage when canceling limit and then entering market

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

    Slippage when canceling limit and then entering market

    Hello,

    I am facing issue on static tick data.
    I have strategy in which I cancel pending limit.
    Then I enter market and get slip 4-5 ticks.
    Strategy runs on tick data and there are no such slips on ES JUN23.

    I do
    CancelOrder
    EnterLong

    And on RB9 I get 6 ticks sl... is there some issue when I cancel order and then do market entry?

    #2
    Hello kujista,

    Thank you for your post.

    So I may assist you more accurately, please answer all of the following questions:
    • What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.?.?.?)
    • Who are you connected to? This is displayed in green in the lower-left corner of the Control Center window.
    • Are you connected to your data feed provider when running this test?
    • What instrument(s) (and expiry if applicable) have you selected?
      • You mentioned "there are no such slips on ES JUN23" though I am not sure which instrument you are experiencing this on.
    • What Data Series Type have you selected? Example: Tick, Minute, Day
    • Is this happening on a backtest/historical data or in real-time? Are you testing on a simulated account or a live account?
    • Is your strategy a multi-instrument or multi-time frame strategy?
    • Do you receive an error on the screen? Are there errors on the Log tab of the Control Center? If so, what do these errors report?
    ​I look forward to your reply.

    Comment


      #3
      Hi,
      - NT Version is 8.1.1.3
      - I am connected to Simulation account DEMO1031070
      - I test it on instrument ES JUN2023
      I have multi time frame strategy
      BarsArray[0] - Volumetric RangeBars 9
      BarsArray[1] - Tick 1 data

      On BarsArray(1) - i analyse price and place CancelOrder and then EnterLong

      - this bug i see in chart on historical data
      - there is no error in control center only big slip

      Comment


        #4
        Hello kujista,

        Thank you for your reply.

        Slippage is a property that may be set in the strategy settings to determine the amount of slippage to apply in the historical processing of the strategy. You could try adjusting this parameter until the desired amount of slippage is applied. For more information about strategy properties:


        Please let us know if we may be of further assistance.

        Comment


          #5
          i do not set slippage in strategy but i get it when i make entry i print close price on tick chart which shows 4000 after performin cancleorder i make entrylong and fill prace is 4001,5 - three ticks slipage i do net get why

          Comment


            #6
            Hello kujista,

            Thank you for your reply.

            I suggest adding additional print statements and comparing them to the Trace Orders output as well. TraceOrders may be set to true in State.SetDefaults, as described in the help guide here:


            You could print the Close price of the primary series, the secondary series, and any other details you'd like regarding when the order is submitted and when it is filled. For more information about using prints to debug a script:


            Submitting the orders to the added 1-tick series should help to get intrabar granularity on the backtest (as described in the reference sample here), though it is still important to understand how order fills are processed historically and the possible discrepancies between real-time and backtest. The following resources cover this topic:




            Please let us know if we may be of further assistance.

            Comment


              #7
              Hello,

              I guess I know where is problem, but do not know how to solve it. Please see attached image it should explain problem

              I also include TraceOrders for the situation
              Code:
              10.03.2023 17:45:06 Strategy 'RangeBarsIntraday/293519407': Cancelled custom managed order: orderId='NT-00134-302' account='Sim101' name='TradeSet #1(Limit_VPOC)' orderState=Working instrument='ES JUN23' orderAction=Buy orderType='Limit' limitPrice=3956 stopPrice=0 quantity=1 tif=Day oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-03-10 17:45:01' gtd='2099-12-01' statementDate='2023-04-22'
              10.03.2023 17:45:06 Strategy 'RangeBarsIntraday/293519407': Entered internal SubmitOrderManaged() method at 10.03.2023 17:45:06: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='TradeSet #1(Limit_VPOC)' FromEntrySignal=''
              10.03.2023 17:45:06 Strategy 'RangeBarsIntraday/293519407': Entered internal SetStopTarget() method: Type=Stop FromEntrySignal='TradeSet #1(Limit_VPOC)' Mode=Price Value=3954,5 IsSimulatedStop=False IsMarketIfTouched=False
              10.03.2023 17:45:06 Strategy 'RangeBarsIntraday/293519407': Amended stop order orderId='NT-00136-302' account='Sim101' name='Stop loss' orderState=Working instrument='ES JUN23' orderAction=Sell orderType='Stop Market' limitPrice=0 stopPrice=3960.75 quantity=1 tif=Day oco='NT-00068-302' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-03-10 17:45:06' gtd='2099-12-01' statementDate='2023-04-22' stopPriceChanged=3954,5
              10.03.2023 17:45:06 Strategy 'RangeBarsIntraday/293519407': Entered internal SetStopTarget() method: Type=Target FromEntrySignal='TradeSet #1(Limit_VPOC)' Mode=Price Value=3958,875 IsSimulatedStop=False IsMarketIfTouched=False
              10.03.2023 17:45:06 Strategy 'RangeBarsIntraday/293519407': Amended target order orderId='NT-00137-302' account='Sim101' name='Profit target' orderState=Working instrument='ES JUN23' orderAction=Sell orderType='Limit' limitPrice=3960.75 stopPrice=0 quantity=1 tif=Day oco='NT-00068-302' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2023-03-10 17:45:06' gtd='2099-12-01' statementDate='2023-04-22' limitPriceChanged=3959
              I also made simple logger which shows the problem
              1. Here I place limit pending
              Code:
              10.03.2023 17:45:01 LIMIT PENDING @3956
              2. Siituation when limit was not filled so i cancel it and want to go market long at price 3956,25 (in TraceOrders it is done BarsInProgress = 0 - tick data have index 2
              Code:
              10.03.2023 17:45:06 --- TRADE --- CHANGING LIMIT TO MARKET LONG @ 3956,25 REQUIRED PRICE: 3956,25
              10.03.2023 17:45:06 --- TRADE --- LIMIT CANCELED MARKETPOSITION: Flat
              3. Market Long Filled at wrong price 3957,25 coresponding to close of previous green candle
              Code:
              10.03.2023 17:45:06 --- TRADE --- MARKET ENTRY LONG FILLED AT: 3957,25 REQUIRED: 3956,25(Slip: 4)
              10.03.2023 17:45:06 --- TRADE --- PLACED STOP LOSS 3954,5
              10.03.2023 17:45:06 --- TRADE --- PLACED PROFIT TARGET AT 3958,875
              10.03.2023 17:45:14 --- TRADE --- STOP LOSS HIT (TradeSet #1(Limit_VPOC)) AT 3954,5 LOSS: 11 TICKS
              Do I get the whole situation OK? I would like to make same entries in chart window as I want to have live. is it possible?
              How should I proceed? Thanks for your help

              Pavel Kujal

              Click image for larger version

Name:	bug.png
Views:	113
Size:	1.03 MB
ID:	1247656
              Attached Files

              Comment


                #8
                Hello Pavel,

                Thank you for your reply.

                You mentioned that the market order is happening on BarsInProgress = 0 in your screenshot and also said that, "in TraceOrders it is done BarsInProgress = 0"
                This helps to understand why the order fill price is the Close price of the previous bar. The historical fill algorithm is based on OHLC values, and if it used BarsInProgress = 0 then the fill would have to be on the OHLC of the previous bar:


                What I suggest is adjusting your script to submit the market order to one of the added data series, such as index 2 that you mentioned for tick data. You could use the syntax available for a market order, like ExitLong() or ExitShort(), that allows you to define the barsInProgressIndex:By submitting the market order to the smaller data series rather than the primary data series, you should be able to see fill prices that are closer to what you are looking for.

                Please let us know if we may be of further assistance.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                62 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                134 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                75 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                45 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                50 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X