Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ATM Strategy Inside Bar

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

    #31
    Chelsea,

    Circling back on the exit on session close, I have noticed that instead of my strategy exiting 30 seconds before the session close (as selected when I enabled the strategy and ExitOnSessionCloseSeconds = 30 under StateDefaults) it is exiting at the start of the last candle. See below pic of the code I am using and a pic of the output window. In the below pic, I am using the 5 min chart of the ES.

    Click image for larger version

Name:	image.png
Views:	104
Size:	24.4 KB
ID:	1314386
    Click image for larger version

Name:	image.png
Views:	92
Size:	32.0 KB
ID:	1314387

    ​The same happens when I use the 15 min chart. exitOnCloseWait will change to true at the start of the last candle of the trading session. So on the 15 min chart, exitOnCloseWait will change to true immediately at 3:45pm EST instead of 30 seconds prior to session close which is what I have set for ExitOnSessionCloseSeconds. Whatever time chart I use, it seems to always change to true at the start of the last candle. Why would this be happening?

    Comment


      #32
      Hello algospoke,

      The print of Time[0] will be the close time of the bar, even if printing while the bar is forming.

      In realtime, if you want to print the current computer time instead of the end of bar time, print DateTime.Now.

      Further, use Calculate.OnEachTick or .OnPriceChange if you would like to see bar updates for each tick or price change before the bar closes.
      Chelsea B.NinjaTrader Customer Service

      Comment


        #33
        Chelsea,

        When I use DateTime.Now in playback, it prints the current time of when I am running the playback instead of the time in the playback.

        My original question was why is exitOnCloseWait being set to true on the start of the last candle (On 5 min chart - it occurs at 3:55pm EST or on a 15 min chart it occurs at 3:45pm EST) when I have ExitOnSessionCloseSeconds = 30? Shouldn't it be set to true at 3:59:30pm EST regardless of which time based chart I am using?

        Thanks

        Comment


          #34
          Hello algospoke,

          This would depend on if this is real-time or historical.

          In historical the exit on close behavior occurs when the bar closes, but in real-time this would occur at the number of seconds before the end of the session as specified.

          The exitOnCloseWait is being assigned from OnBarUpdate() and can only be updated to true 30 seconds before the end of the session if the bar is updating before it closes based on the Calculate setting.

          In the output you have provided in post # 31 I am seeing the message of exitOnCloseWait true at 4:00 PM. This may have been 30 seconds before the end of the session but the timestamp is showing the close time of the bar.

          In playback to get the playback time use Cbi.Connection.PlaybackConnection.Now. (To check if the connection is playback compare Cbi.Connection.PlaybackConnection != null)
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          50 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          126 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          69 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X