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

Close a position at a certain time of the day

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

    Close a position at a certain time of the day

    Hi

    I would like to know syntax of the action that closes a position.
    My current syntax is the following:

    if ((Position.MarketPosition == MarketPosition.Long)
    && Times[0][0].TimeOfDay >= DateTime.Parse("07:30", System.Globalization.CultureInfo.InvariantCulture) )

    If the text above is true I want the order to be closed.

    Thanks in advance


    #2
    Hello henryd333,

    Thank you for the post.

    To close a position you would need to submit an order which brings you back to flat. If you are long you could submit an ExitLong order to become flat.



    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Nicholewatkinsi, Today, 10:53 PM
    0 responses
    5 views
    0 likes
    Last Post Nicholewatkinsi  
    Started by dward123, 01-02-2024, 09:59 PM
    4 responses
    175 views
    0 likes
    Last Post Lancer
    by Lancer
     
    Started by ETFVoyageur, Today, 04:00 PM
    2 responses
    19 views
    0 likes
    Last Post ETFVoyageur  
    Started by AaronKTradingForum, Today, 03:44 PM
    1 response
    14 views
    0 likes
    Last Post AaronKTradingForum  
    Started by Felix Reichert, 04-26-2024, 02:12 PM
    11 responses
    80 views
    0 likes
    Last Post Felix Reichert  
    Working...
    X