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

EnterLong and EnterShort to trigger on Close not Open

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

    EnterLong and EnterShort to trigger on Close not Open

    I am currently calculating entry signal at Close of bars. When I call EnterLong or EnterShort at that close, the strategy, enters the trade on Open of the next bar.

    How can I make the strategy enter the trade on Close of the next bar instead?

    This is all for Historical analysis not live data. The bars are Daily bars.
    I have already set CalculateOnBarClose = true

    #2
    Hello afshinmoshrefi,

    To have a strategy purchase not the open of the bar immediately after the condition is true, but the bar after, you could set CurrentBar to a variable then have another if statement check if the CurrentBar is >= the variable+1, and if so enterlong. An example of this can be seen in the attached sample.

    Regarding having the strategy execute on the close rather than the open, the attached strategy adds a 2nd bar series and a time filter to accomplish this.

    Please let us know if you need further assistance.
    Attached Files
    Last edited by NinjaTrader_AlanP; 04-27-2017, 04:47 PM.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Thanks Alan. I was hoping I could accomplish this task with daily bars only. Is that possible or do I require using second or tick data to do this task.

      Comment


        #4
        Hello afshinmoshrefi,

        The strategy I put together is applied to a daily chart/data, however uses a secondary series of tick to accomplish the exiting on close. I'm not sure how you could accomplish what you're looking to do without a secondary data series.

        If you formulate an idea I'd be interested to know.

        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Radano, 06-10-2021, 01:40 AM
        19 responses
        606 views
        0 likes
        Last Post Radano
        by Radano
         
        Started by KenneGaray, Today, 03:48 AM
        0 responses
        4 views
        0 likes
        Last Post KenneGaray  
        Started by thanajo, 05-04-2021, 02:11 AM
        4 responses
        470 views
        0 likes
        Last Post tradingnasdaqprueba  
        Started by aa731, Today, 02:54 AM
        0 responses
        5 views
        0 likes
        Last Post aa731
        by aa731
         
        Started by Christopher_R, Today, 12:29 AM
        0 responses
        11 views
        0 likes
        Last Post Christopher_R  
        Working...
        X