Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 popecapllc, 08-09-2023, 07:42 PM
        8 responses
        1,338 views
        0 likes
        Last Post Johng22
        by Johng22
         
        Started by ETFVoyageur, 04-30-2024, 02:04 PM
        11 responses
        98 views
        0 likes
        Last Post ETFVoyageur  
        Started by bubblegum, 03-18-2024, 10:41 AM
        3 responses
        44 views
        0 likes
        Last Post vjsworld  
        Started by JamesK1, Today, 02:48 PM
        1 response
        12 views
        0 likes
        Last Post JamesK1
        by JamesK1
         
        Started by llanqui, Today, 03:51 PM
        0 responses
        10 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Working...
        X