Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Handling of Exit Long and Exit Short before EOD

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

    Handling of Exit Long and Exit Short before EOD

    In the condition builder I check for ToTime>21:45 and want as action to close my position. Can I give the ExitLong as well as the ExitShort command at the same time? What will be the result of the ExitShort command when you have a Long position or no position?
    Is there a smarter way to close your position indepent it is Long or Short?

    #2
    this is what I do:

    if (Position.MarketPosition != MarketPosition.Flat) {


    if (Position.MarketPosition == MarketPosition.Long) {
    //exit long code here
    }

    if (Position.MarketPosition == MarketPosition.Short) {
    //exit short code here
    }
    }

    Comment


      #3
      Yes, you can have both. One or both are ignored if a position does not exist to be closed.
      RayNinjaTrader Customer Service

      Comment


        #4
        The help for ExitShort says "This method is ignored if a short position does not exist", so it should be OK to just issue both the ExitShort and the ExitLong when you want to flatten your strategy.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        62 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        33 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        44 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        58 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        47 views
        0 likes
        Last Post CarlTrading  
        Working...
        X