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 all positions for the chart's symbol

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

    Close all positions for the chart's symbol

    Hello,
    what is the correct instruction to run on a NinjaTrader7 script to close all positions of the same symbol of the current Chart regardless of whether they were launched manually or with a strategy? Those of the actual account with the broker (or Market Replay if I am connected to it)
    So if the Chart is ES 12-19 I want to close any open position ES 12-19 regardless of whom - or how they were opened it.

    Similarly what's the best way to know if I have any open positions of the same symbol of my chart ES 12-19, those of the actual account with the broker (or Market Replay if I am connected to it).

    And similarly what's the best way to cancel any order for the same symbol of my chart ES 12-19, those of the actual account with the broker.

    Thank you.
    Giogio
    Last edited by giogio1; 11-11-2019, 01:55 AM.

    #2
    Hello giogio1,

    Thank you for your note.

    If you're not looking to do this programatically, just hitting the Close button in any chart will result in all pending orders being canceled and all existing positions being closed on the account/instrument combination that is selected. Any running strategies will be stopped and their positions exited and pending orders cancelled.

    If you're looking to do this from NinjaScript, unfortunately that would not be supported in NinjaTrader 7. You would also not be able to detect manual orders on the account from within a strategy in a supported manner. However, NinjaTrader 8 would support this.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      You cannot flatten all positions (manual and strategy) of a single symbol in NinjaTrader 7.

      You can, however, flatten everything, regardless of symbol and mode of creation.

      --==0==--

      How to "Flatten Everything"?

      Manually, from Control Center menu,
      CC -> Files -> Flatten Everything

      Manually, from Positions Tab,
      Right click on position, select Flatten Everything from context menu

      Programmatically, try this,


      Also, you can try this,


      Lastly, study these,



      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by cmtjoancolmenero, Yesterday, 03:58 PM
      11 responses
      39 views
      0 likes
      Last Post cmtjoancolmenero  
      Started by FrazMann, Today, 11:21 AM
      0 responses
      5 views
      0 likes
      Last Post FrazMann  
      Started by geddyisodin, Yesterday, 05:20 AM
      8 responses
      52 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by DayTradingDEMON, Today, 09:28 AM
      4 responses
      27 views
      0 likes
      Last Post DayTradingDEMON  
      Started by George21, Today, 10:07 AM
      1 response
      22 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Working...
      X