• 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 vivekniwas, Today, 10:21 PM
      0 responses
      1 view
      0 likes
      Last Post vivekniwas  
      Started by saltminer, Today, 06:22 PM
      0 responses
      2 views
      0 likes
      Last Post saltminer  
      Started by saltminer, Today, 06:20 PM
      0 responses
      1 view
      0 likes
      Last Post saltminer  
      Started by escobar63, Today, 05:06 PM
      0 responses
      7 views
      0 likes
      Last Post escobar63  
      Started by i2w8am9ii2, Today, 04:41 PM
      0 responses
      7 views
      0 likes
      Last Post i2w8am9ii2  
      Working...
      X