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

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 agclub, Yesterday, 08:57 PM
        2 responses
        16 views
        0 likes
        Last Post agclub
        by agclub
         
        Started by cre8able, 04-17-2024, 04:16 PM
        6 responses
        56 views
        0 likes
        Last Post cre8able  
        Started by Mindset, 05-06-2023, 09:03 PM
        13 responses
        293 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by kaywai, 09-01-2023, 08:44 PM
        4 responses
        600 views
        0 likes
        Last Post joselube001  
        Started by dpolyakov, 03-29-2024, 11:30 AM
        3 responses
        135 views
        2 likes
        Last Post sonia0101  
        Working...
        X