Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

entry and exit

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

    entry and exit

    I am trying to have my strategy enter the market at the open of the market and exit the market at the close of the the market for the day. I am using yahoo data. I've tried using exitonclose but whenever I backtest it only exits on the last day i have set it up to trade on, rather than closing everyday throughout the range of days I have set up. I also thought about using BarsSinceEntry() > 1 to exit my strategy but that doesn't seem to work either.

    #2
    Hi Wes, in order to both enter and exit a trade on the same day you'll need to add detail and backtest with intrabar granularity. Unfortunately, that requires minute/tick data.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Ok well how would I enter one day and exit the next day.

      Also if I have three indexes and format a code like so:

      if (Closes[1][0] < Closes[1][1] && Closes[2][0] < Closes[2][1] && Closes[3][0] < Closes[3][1])

      Exit long
      Will it exit if one of the the indexes is down or will it exit when all three are down?

      Comment


        #4
        To enter one day and exit the next, you'd program it just as usual. In OnBarUpdate:
        Code:
        if (Close[0] > Close[1])
            EnterLong(); //this would enter long at the open of the day after the bar that the conditions were true
        
        if (Close[0] < Close[1])
            ExitLong() //this would exit the long at the open of the day after the conditions were true
        The code you posted will exit if all three are down.

        In C# (and many other languages) && is the logical operator AND and || is the logical operator OR.

        If, for example, you'd like to exit when any of the three were down, you could do this:
        Code:
        if (Closes[1][0] < Closes[1][1] || Closes[2][0] < Closes[2][1] || Closes[3][0] < Closes[3][1])
        You could also group these operators if you'd like:
        Code:
        if ((Closes[1][0] < Closes[1][1] && Closes[2][0] < Closes[2][1]) && (Closes[3][0] < Closes[3][1] && someOtherCondition))
        AustinNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        67 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        36 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        59 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        62 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        53 views
        0 likes
        Last Post CarlTrading  
        Working...
        X