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 ghoul, Today, 06:02 PM
      3 responses
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      44 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      20 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      180 views
      0 likes
      Last Post jeronymite  
      Started by DanielSanMartin, Yesterday, 02:37 PM
      2 responses
      13 views
      0 likes
      Last Post DanielSanMartin  
      Working...
      X