Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Open position on specific time

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

    Open position on specific time

    Hi,

    I'm trying to open a position in different futures contracts with the Strategy Builder.
    I'm using the NinjaTrader Continuum Data feed, and I'm not sure if this is related to my feed or to my code.
    The strategy is not producing any entries. Without filtering for time, it does produce entries on Thursdays and exits on Fridays.
    My final goal is to place a trade in the evening hours of Thursday and exit in the evening hours of Friday.

    Here's my code:

    Code:
    // Set 1
    if ((Times[0][0].DayOfWeek == DayOfWeek.Wednesday)
    && (Times[0][0].TimeOfDay > new TimeSpan(15, 0, 0))
    && (Times[0][0].TimeOfDay < new TimeSpan(15, 30, 0)))
    {
        EnterLong(Convert.ToInt32(DefaultQuantity), "");
    }
    
    // Set 2
    if (Times[0][0].DayOfWeek == DayOfWeek.Thursday)
    {
        ExitLong(Convert.ToInt32(DefaultQuantity), "", "");
    }

    #2
    Hello dmaucher,

    Thanks for your post and welcome to the NinjaTrader forums!

    In reading your post I am a bit confused so I have these questions.

    "I'm trying to open a position in different futures contracts with the Strategy Builder." Do you mean you want to open a position on a contract other than the one the Strategy is applied to? The Strategy Builder can only send orders to the primary series which would be the charts primary series.

    The code you show references Wednesday and Thursday and you are advising the orders are on Thursday and Friday?

    Are you testing this on live data, historical data, or Playback with Market replay data?

    If testing on historical data, are you using the Strategy Aanalyzer?

    What instrument, bar type, and bar size are you testing with?

    What is the Calculate setting of the strategy? (as found in the "default properties" section of the Strategy Builder).

    Comment


      #3
      Do you mean you want to open a position on a contract other than the one the Strategy is applied to? The Strategy Builder can only send orders to the primary series which would be the charts primary series.
      No, I only want to use the strategy on different contracts at a later stage. For now, I'm only applying it to a single chart and I'm only expecting it to work on this single chart.

      The code you show references Wednesday and Thursday and you are advising the orders are on Thursday and Friday?
      Yes, it only seems to work this way. I guess this has to do with the bar index? When I'm using
      Code:
      Times[0][0].DayOfWeek == DayOfWeek.Thursday
      to open a trade, the trade will be opened on a Friday instead of a Thursday. So I just stepped back one more day but I haven't figured out yet, why this happens.

      Are you testing this on live data, historical data, or Playback with Market replay data?
      I'm testing with Kinetick - End Of Day (Free) and NinjaTrader Continuum (Demo)

      If testing on historical data, are you using the Strategy Aanalyzer?
      No, I hit compile and then activate the strategy in the 'Strategies' tab. It then shows my entries and exits on the chart.

      What instrument, bar type, and bar size are you testing with?
      GC 06-21, Candlestick, daily

      What is the Calculate setting of the strategy?
      On bar close

      Comment


        #4
        Hello dmaucher,

        Thanks for your reply.

        When applying a strategy to historical data, the strategy code will run once per bar, at the end of the bar. Any orders placed when the bar closes would be filled on the next bar and this is why your entry/exits shift a day (using daily bars) (when not using the time filter)

        When you use the time filter it will not place any orders because the time condition does not become true, again this is because the only time the script is run is at the end of the daily bar.

        You would have to use intraday bars in order to trigger your time filter. While you have the live data demo you can create 1 minute chart and work on that basis (if you wish).



        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by NullPointStrategies, Today, 05:17 AM
        0 responses
        53 views
        0 likes
        Last Post NullPointStrategies  
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        130 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        70 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        44 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        49 views
        0 likes
        Last Post TheRealMorford  
        Working...
        X