Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Buy on the close

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

    Buy on the close

    I know this usually cannot be done but I would like to backtest my code with entries on the close of present bar where signal is generated rather than on the open of the next daily bar. How can I modify the entry below to have the order placed at the close?

    Code:
    if (Close[0] > Close[10])
                {
                    EnterLong(DefaultQuantity, "Long");
                }
    Thanks
    Last edited by ricko; 10-10-2015, 10:54 AM.

    #2
    Hello Ricko,

    Thank you for writing in. Please see the following reference sample for how you can go about accomplishing this: http://ninjatrader.com/support/forum...ead.php?t=6652

    Please let me know if you have any questions or if I may be of further assistance.
    Michael M.NinjaTrader Quality Assurance

    Comment


      #3
      Thank you Michael. I only use daily data and I do not want to add another timeframe. I could not find any reference of how to modify my script to enter the trade at the close of the current bar.

      Comment


        #4
        Hello ricko,

        Unfortunately this is not possible in the way you are describing. You can enter prior to the close of the current bar but to do this requires your strategy to calculate intrabar.

        For a realtime strategy in NinjaTrader 7, you could simply set CalculateOnBarClose equal to false and create conditions to determine when to actually enter based on the period of the data series you were using. This approach would also work for a backtestable strategy in NinjaTrader 8 due to the added feature of Tick Replay.

        To accomplish this in a backtestable strategy in NinjaTrader 7, you will have to add a secondary data series and I have provided an example of this in my earlier post.

        Please let me know if you have any questions or if I may be of further assistance.
        Michael M.NinjaTrader Quality Assurance

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sjsj2732, Yesterday, 04:31 AM
        0 responses
        33 views
        0 likes
        Last Post sjsj2732  
        Started by NullPointStrategies, 03-13-2026, 05:17 AM
        0 responses
        286 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        284 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        133 views
        1 like
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        91 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Working...
        X