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 not executed on start of daily bars

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

    Order not executed on start of daily bars

    Hi,
    there is an issue with executing orders on daily bars.
    I am using daily bars which are build from minute bars. The setting is 1440 minutes for the daily bar. Break at EOD is also set to true.

    If you run the attached strategy you will see an message like this in the NS Output:
    16.12.2019 23:00:00 Strategy 'StartOfDayTradingTest/251632721': Entered internal SubmitOrderManaged() method at 16.12.2019 23:00:00: BarsInProgress=0 Action=Buy OrderType=Market Quantity=1 LimitPrice=0 StopPrice=0 SignalName='L' FromEntrySignal=''
    16.12.2019 23:00:00 Strategy 'StartOfDayTradingTest/251632721': Cancelled order due to end of session handling: BarsInProgress=0, orderId='NT-00245-304' account='Sim101' name='L' orderState=Working instrument='ES 03-22' orderAction=Buy orderType='Market' limitPrice=0 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2019-12-16 23:00:00' gtd='2099-12-01' statementDate='2021-12-22'

    That means that the order got cancelled before it was executed on the "internal market". I think there is no reason why it is not executed. The EOD should come AFTER the execution signal at the beginning of the bar.

    If you add the 1 minute data series and use the code in the comments, it will work perfectly. Although the signal is generated 1 minute after opening.

    My suggestion is to modify the back test logic and let the signal at the beginning of the day be executed.

    Thanks,
    Klaus

    Attached Files

    #2
    Hello klaus w,

    Thank you for your post.

    During a backtest you can select conservative or liberal fill algorithms which will produce different results. Fills are determined based on 4 data points, OHLC of a bar since that is the only information that is known during a backtest and there will be no intra-bar data. This means actions cannot happen intra-bar, fills cannot happen intra-bar. All prices and actions come from and occur when the bar closes as this is all the information that is known.

    Because of this, OnBarUpdate will only update 'On bar close' as it does not have the intra-bar information necessary for 'On price change' or 'On each tick'.

    Also, here is a link to the differences on real-time vs backtest (historical).
    http://ninjatrader.com/support/helpG...ime_vs_bac.htm

    Adding intra-bar granularity can help with this as you've seen adding the 1 minute series to your script. However, keep in mind that even with that 1 minute series added, if the order is triggered on that first minute bar it will actually be placed on the second since that too can only run OnBarClose.

    So basically what's occurring without adding that intrabar granularity with the minute series is that the order is generated when the daily bar closes, and is immediately cancelled since that would hit the close at end of day logic. Adding the intrabar granularity would be necessary for it to function as you'd expect.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by tkaboris, Today, 05:13 PM
    0 responses
    2 views
    0 likes
    Last Post tkaboris  
    Started by GussJ, 03-04-2020, 03:11 PM
    16 responses
    3,281 views
    0 likes
    Last Post Leafcutter  
    Started by WHICKED, Today, 12:45 PM
    2 responses
    19 views
    0 likes
    Last Post WHICKED
    by WHICKED
     
    Started by Tim-c, Today, 02:10 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Taddypole, Today, 02:47 PM
    0 responses
    5 views
    0 likes
    Last Post Taddypole  
    Working...
    X