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

How to enter on close[0]

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

    How to enter on close[0]

    Hi,

    I'm trying a simple strategy in strategy analyzer. I have to wait for the daily candle to close for signal confirmation, so then, I have to enter immediately. But, the problem is that the next available price to enter is at the open of the following bar, in this case the next day, so my enter will be different because the open gap in price.

    Is there some idea to code the enter at the close of the signal bar, not waiting to the open of next day?

    Thanks

    #2
    Hello federicoo,

    Thank you for your post.

    If you were to run your strategy in real-time, would the signal confirmation happen in the middle of the daily bar rather than when the bar closes? When backtesting in the Strategy Analyzer, order fills are processed based on OHLC data for each candle. This means that backtesting is processed On Bar Close rather than allowing for intrabar fills. In order to get more realistic fills, you can either set the Order Fill Resolution to High, which adds an additional data series to process orders on. You can set this to the most granular option of 1-tick, although this could result in higher resource utilization and longer loading times for the backtest to complete. Alternatively, you can adjust the logic in your strategy to submit orders to a 1-tick data series as demonstrated in the following reference sample:
    https://ninjatrader.com/support/help...ipt_strate.htm

    We have more information about the discrepancies between real-time and backtests here:
    https://ninjatrader.com/support/help...ime_vs_bac.htm

    Please let me know if I may be of further assistance.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Hello Emily,

      I should wait for the day close, but I can enter some ticks or some seconds before the close to avoid waiting for the open of next day. This way the entry price should be almost the same of close[0].

      But, I want to test this strategy in strategy analyzer, before run this on real-time, so I think there is not possible to use the granular option of 1-tick, isn't it? nor seconds... may be the nearest I can use is 1-minute bars in historic data.

      Thanks

      Comment


        #4
        Hello federicoo,

        A strategy that adds a 1-tick series with AddDataSeries() can be backtested in the Strategy Analyzer.

        Try testing the reference sample to demonstrate.
        https://ninjatrader.com/support/help...ipt_strate.htm

        For Calculate.OnEachTick or .OnPriceChange to work historically, TickReplay must be enabled.

        Below is a link to a forum post that details.
        https://ninjatrader.com/support/foru...377#post773377
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks Chelsea,

          Most of these links are not available...

          Click image for larger version

Name:	image.png
Views:	14
Size:	73.9 KB
ID:	1227116

          Comment


            #6
            Hello federicoo,

            Thank you for your reply.

            I was able to open the link Chelsea shared and click on the links shown in your screenshot without issues. What message are you receiving indicating that the links are not available?

            I look forward to your reply.
            Emily C.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by jaybedreamin, Yesterday, 06:06 PM
            1 response
            35 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by ballston, 05-07-2021, 06:32 AM
            6 responses
            253 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by demarcog, Today, 08:51 AM
            0 responses
            1 view
            0 likes
            Last Post demarcog  
            Started by futuros, 01-26-2023, 05:10 PM
            3 responses
            40 views
            0 likes
            Last Post NinjaTrader_ChrisL  
            Started by number1, Yesterday, 09:13 PM
            1 response
            33 views
            0 likes
            Last Post NinjaTrader_Sev  
            Working...
            X