• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Code NT7 for Exit long or Short at a 15:40ET

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

    Code NT7 for Exit long or Short at a 15:40ET

    what is the code for exiting a long or short trade, or flatten everything, at a specific time?
    thank you

    #2
    Hello bizzz10, and thank you for your question. Since ExitLong and ExitShort are safe to call even if you aren't in a position, the code is simply

    Code:
    // Flatten everything at 4 PM (so 16:00:00) every day
    if (ToTime(Time[0]) > 160000)
    {
        // comment out to just exit long
        ExitShort();
    
        // comment out to just exit short
        ExitLong();
    }
    That would go inside OnBarUpdate. Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      thank you!
      i will test it tomorrow.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Revan, Yesterday, 11:53 PM
      4 responses
      21 views
      0 likes
      Last Post NinjaTrader_Jim  
      Started by Vincere, Today, 03:32 AM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Started by hir04068, Today, 04:26 AM
      0 responses
      5 views
      0 likes
      Last Post hir04068  
      Started by Thomas79, Today, 03:22 AM
      0 responses
      3 views
      0 likes
      Last Post Thomas79  
      Started by pjsmith, Today, 12:50 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_ChrisSch  
      Working...
      X