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 alifarahani, Today, 09:40 AM
        3 responses
        15 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by RookieTrader, Today, 09:37 AM
        4 responses
        17 views
        0 likes
        Last Post RookieTrader  
        Started by PaulMohn, Today, 12:36 PM
        0 responses
        5 views
        0 likes
        Last Post PaulMohn  
        Started by love2code2trade, 04-17-2024, 01:45 PM
        4 responses
        40 views
        0 likes
        Last Post love2code2trade  
        Started by junkone, Today, 11:37 AM
        3 responses
        23 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X