Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trigger a trade on market open, on opening of first bar.

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

    Trigger a trade on market open, on opening of first bar.

    How to do I trigger a trade on market open, on opening of first bar.

    #2
    Hello tomd0361,

    Thanks for your post and welcome to the NinjaTrader forums!

    You would need to use a calculation mode of Calculate.OnPriceChange or Calculate.OnEachTick so that your code will run intrabar.

    Then you can use the system bools of Bars.IsFirstBarOfSession and IsFirstTickOfBar.

    Reference:



    if (Bars.IsFirstBarOfSession && IsFirstTickOfBar)
    {
    // entry order
    }


    Note: the assumption is that you are using a trading hours session where the "Market Open" relates to the opening of the session. If that is not the case then you would need to replace the Bars.IsFirstBarOfSession with a time check of the bar, for example if 8:30 is the opening time and you are using 1 minute bars, you would check the bar (timestamp is based on bar close time) and then on the first tick of that bar perform the entry.

    if (Times[0][0].TimeOfDay == new TimeSpan(8, 31, 0) && IsFirstTickOfBar) //
    {
    // entry order
    }

    Comment


      #3
      Thanks Paul.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by SalmaTrader, 07-07-2026, 10:26 PM
      0 responses
      96 views
      0 likes
      Last Post SalmaTrader  
      Started by CarlTrading, 07-05-2026, 01:16 PM
      0 responses
      51 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 06-17-2026, 10:32 AM
      0 responses
      23 views
      0 likes
      Last Post CaptainJack  
      Started by kinfxhk, 06-17-2026, 04:15 AM
      0 responses
      34 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 06-17-2026, 04:06 AM
      0 responses
      37 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Working...
      X