Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Using IsFirstTickOfBar

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

    Using IsFirstTickOfBar

    I have a strategy which calculates on bar close. When a valid entry condition is met the strategy enters on the close of the following bar.

    I have attempted to use IsFirstTickOfBar to get in on the first tick of the bar following the entry criteria (The strategy is modiified to calculate on each tick and the calculations are modified to look back one bar). This does not seem to work and the strategy still enters on the close of the bar following the entry criteria being met.

    Is there a way of adding a secondary bar series of one tick and so when the entry criteria is met on the primary data series the position is entered immediately on the secondary dataseries?

    So instead of using EnterLong() we use the overload:

    EnterLong(int barsInProgressIndex, int quantity, string signalName)

    where barsInProgressIndex = 1 referring to the secondary dataseries. Would barsinprogress need to equal 1 (secondary data series) to enter a position on the secondary dataseries?


    #2
    Hello mballagan,

    Thank you for the post.

    Was that a historical test where you tried IsFirstTickOfBar? If so, historical tests always work OnBarClose so that would not work in that situation. Adding a secondary series would let you submit orders at a more granular level using the BarsInProgress overload you have pasted. 1 would be the second series.


    I look forward to being of further assistance.

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello mballagan,

      Thank you for the post.

      Was that a historical test where you tried IsFirstTickOfBar? If so, historical tests always work OnBarClose so that would not work in that situation. Adding a secondary series would let you submit orders at a more granular level using the BarsInProgress overload you have pasted. 1 would be the second series.


      I look forward to being of further assistance.
      Thanks for your reply. I was referring to realtime in my last post. So just to clarify would the overloaded EnterLong(int barsInProgressIndex, int quantity, string signalName) be executed within the primary data series logic (BarsInProgress==0) or would need to ensure that this command is executed when BarsInProgress==1 (second data series)?

      Comment


        #4
        Hello mballagan,

        If you are trying to fill the order on a more granular series you would use BarsInProgress 1 in the entry method to specify the secondary series. Realtime orders are submitted immediately when you call the method, if you are seeing the order fill a bar later it may be that the logic is not actually submitting the order immediately but waiting for the next bar to submit the order.


        I look forward to being of further assistance.

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello mballagan,

          If you are trying to fill the order on a more granular series you would use BarsInProgress 1 in the entry method to specify the secondary series. Realtime orders are submitted immediately when you call the method, if you are seeing the order fill a bar later it may be that the logic is not actually submitting the order immediately but waiting for the next bar to submit the order.


          I look forward to being of further assistance.
          Jesse,

          Thanks for your response.

          I understand that the Ninjatrader simulation engine also sometimes creates delays in orders getting filled in order to mimick live trading conditions. Is there a way to alter the behaviour of the simulation engine so that these delays are not activated (in code or otherwise)?



          Comment


            #6
            Hello mballagan,

            There is currently not any way to modify the realtime simulation fill engine. It has preset logic and is not exposed in any type of way that can be edited/have changes made.

            I look forward to being of further assistance.

            Comment


              #7
              Hello FuturesPhantom,

              The main take away from the intrabar granularity samples would be that you submit the orders to BarsInProgress 1 by using the EnterLong(BarsInProgress or EnterShort(BarsInProgress overloads.

              Code:
              EnterLong(int barsInProgressIndex, int quantity, string signalName)
              
              EnterShort(int barsInProgressIndex, int quantity, string signalName)
              All of the order methods have a BarsInProgress overload and you would enter a 1 for the secondary series when you wanted to use a more granular series for fills. The Set methods do not have a BarsInProgress overload, if you wanted to control a target from a secondary series you would need to avoid using the set methods and instead just submit the appropriate type of order for the target you wanted.

              I look forward to being of further assistance.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by NullPointStrategies, Today, 05:17 AM
              0 responses
              44 views
              0 likes
              Last Post NullPointStrategies  
              Started by argusthome, 03-08-2026, 10:06 AM
              0 responses
              126 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              65 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              42 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              46 views
              0 likes
              Last Post TheRealMorford  
              Working...
              X