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

Order filled one bar later

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

    Order filled one bar later

    Hello,

    I'm trying to figure out something while playing with basic stuff.

    I have an indicator (it could be anything) but let's say
    ((Close[2] < Open[2] & Close[1] < Open[1])) which displays the white arrow (see screenshot below).

    Now I use the same exact condition to enter a long position. Something like this:


    if ((Close[2] < Open[2] & Close[1] < Open[1]))
    {
    EnterLong("Long");
    }


    The condition happens (brown arrow) at the same time of the indicator but the order gets placed one bar later (blue arrow). The purple arrow is the exit.

    I would like for the order to be placed at the opening of the bar with the white arrow. How do I accomplish it?

    Click image for larger version

Name:	Annotation 2020-05-25 172140.png
Views:	181
Size:	3.0 KB
ID:	1101604


    Thanks!

    #2
    Hello TexFly,

    Thanks for your post.

    Based on your observations it sounds like you are running the strategy with Calculate.OnBarClose which means any actions determined by your strategy are performed at the end of the bar, such as drawing the white arrow and placing the entry order, however the order cannot be filled until the next bar due to the time it takes to process the order.

    If you are working with live data or Playback with market replay data, you could test working with Calculate.OnPriceChange or Calculate.OnEachTick which would allow you to place the order on the FirstTickOfBar. Reference: https://ninjatrader.com/support/help...ttickofbar.htm

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_PaulH View Post
      Hello TexFly,

      Thanks for your post.

      Based on your observations it sounds like you are running the strategy with Calculate.OnBarClose which means any actions determined by your strategy are performed at the end of the bar, such as drawing the white arrow and placing the entry order, however the order cannot be filled until the next bar due to the time it takes to process the order.

      If you are working with live data or Playback with market replay data, you could test working with Calculate.OnPriceChange or Calculate.OnEachTick which would allow you to place the order on the FirstTickOfBar. Reference: https://ninjatrader.com/support/help...ttickofbar.htm
      Thanks Paul. I will take a look!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by wzgy0920, 04-20-2024, 06:09 PM
      2 responses
      26 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, 02-22-2024, 01:11 AM
      5 responses
      32 views
      0 likes
      Last Post wzgy0920  
      Started by wzgy0920, Yesterday, 09:53 PM
      2 responses
      49 views
      0 likes
      Last Post wzgy0920  
      Started by Kensonprib, 04-28-2021, 10:11 AM
      5 responses
      191 views
      0 likes
      Last Post Hasadafa  
      Started by GussJ, 03-04-2020, 03:11 PM
      11 responses
      3,230 views
      0 likes
      Last Post xiinteractive  
      Working...
      X