• 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 Jschmelz, Today, 01:13 PM
      0 responses
      5 views
      0 likes
      Last Post Jschmelz  
      Started by Newtrader101, Today, 12:37 PM
      0 responses
      6 views
      0 likes
      Last Post Newtrader101  
      Started by shishir_nse, Today, 11:13 AM
      0 responses
      6 views
      0 likes
      Last Post shishir_nse  
      Started by shishir_nse, Today, 11:02 AM
      0 responses
      3 views
      0 likes
      Last Post shishir_nse  
      Started by 12VMan, Today, 07:15 AM
      3 responses
      18 views
      0 likes
      Last Post Lancer
      by Lancer
       
      Working...
      X