• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using Enter Stop Market with Tick Replay and Bar Index

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

    Using Enter Stop Market with Tick Replay and Bar Index

    Hey guys,

    I could use some help understanding why my orders don't fill on backtests when I use the Tick Replay checkbox. I have a custom indicator that needs to have 2 additional data series loaded and it needs Tick Replay. So, when I go to run my simple strategy, I can see the strategy attempting to place EnterLongStopMarket orders 1 or 2 ticks above the current High but they do not fill. I've tried changing that Bar Index from 0 - 2 and it didn't change. Can you help clarify?
    I've attached my simple strategy and if need be, the indicators required to run it.
    Attached Files

    #2
    Hello PN720,

    Thank you for the post.

    One way to determine what is going on would be to use TraceOrders. I suspect from the syntax you used that the order is being expired.
    https://ninjatrader.com/support/help...ub=TraceOrders

    You are currently using EnterLongStopMarket(0, false, 1, High[0] + 1 * TickSize, "Long1");

    isLiveUntilCancelled is false so this order can be expired after 1 bar elapses unless the order method is called again on the next bar, if your condition fails to continue to be true it should be expiring the order.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      I changed that from false to true and I can see orders being placed now. But, I thought that under Managed Orders, if the next bar doesn't fill the order, then it is cancelled, right? For my other strategies, this works:

      EnterLongStopMarket(1, EntryPrice , "Long1");

      Can you help me understand why?

      Comment


        #4
        Hello PN720,

        Correct under the managed approach if the next bar is processed and the entry method was not called again or the order did not fill it would be expired. With tick granularity added and secondary series, this would decrease the time the order stays active if your condition fails to remain true. this could also decrease the ranges of prices the order will see before expired preventing fills. I can't really speak of differences between your scripts as I don't have the full context however I would estimate it is likely a granularity difference if the other script had different series or was not being used with TickReplay.

        I look forward to being of further assistance.



        JesseNinjaTrader Customer Service

        Comment


          #5
          Since I'm going to change over any of my scripts that use Tick Replay to IsLiveUntilCancelled = True, how can I cancel the order if the close of the next bar doesn't fulfill it? I'm using Calculate.OnBarClose for my strategy if that makes a difference.

          Comment


            #6

            Hello PN720,

            You would need to use Order objects as that is what CancelOrder requires. In the sample that you provided that is the very minimum code required to place an order with targets, however, that does not account for all use cases mainly just the case where prices will fill the order within 1 bar. The managed approach cleans up for you in case the order did not fill. When you have finer granularity such as 1 tick the prices may not fill that order which then requires IsLiveUntilCancelled. Because of this, you may need to add some more logic to account for the now active order.

            We have a sample of using CancelOrder here: https://ninjatrader.com/support/help...thod_to_ca.htm

            Depending on your goal, you would need to call CancelOrder when appropriate. The sample you provided is a multi-series but you do not use BarsInProgress to know which series is currently calling OnBarUpdate. This means OnBarUpdate is being called for each 1 tick(tick replay), 3 minutes, 9 minutes and whatever the primary series is. 1 bar is currently at the granularity of 1 tick, so additional logic is needed to make the script understand what 1 bar should be. There are some examples of working with multiple series in the following page, you would likely need a condition for one of the BarsInProgress or to also use IsFirstTickOfBar to denote when a bar closes: https://ninjatrader.com/support/help...lightsub=multi

            I would also suggest reading the tick replay documentation if you have not, this is not generally to be used in a backtest as it does not add any extra accuracy. You can also look at using the higher order fill resolution:

            https://ninjatrader.com/support/help...sub=tickreplay
            https://ninjatrader.com/support/help...ical_fill_.htm

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by digibob, Today, 02:47 AM
            0 responses
            1 view
            0 likes
            Last Post digibob
            by digibob
             
            Started by NinjaCustomer, Today, 12:57 AM
            1 response
            4 views
            0 likes
            Last Post NinjaCustomer  
            Started by lancasterstephen, Today, 12:09 AM
            1 response
            5 views
            0 likes
            Last Post lancasterstephen  
            Started by liltr3d, Yesterday, 10:52 PM
            0 responses
            4 views
            0 likes
            Last Post liltr3d
            by liltr3d
             
            Started by Longhornmark, Yesterday, 08:25 AM
            3 responses
            13 views
            0 likes
            Last Post bltdavid  
            Working...
            X