Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

chat access

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

    chat access

    Is it possible to access the close button of the chart trade from addons?
    What do I call it to create a panic button?​

    #2
    You'd probably call such a panic button 'Flatten Everything'.

    Chart Trader's right click menu already has it.

    You could also call Flatten() directly.



    Comment


      #3
      Yes, of course, the fact is that I have a replicator that when an operation is left open in one of the replicated accounts it is detached from the addons and I can only close it from the close button of the chart, that is why I want to access that button from the code, that is:
      foreach (var position in submissionAccountMaestra.Positions)
      {
      if (position.MarketPosition != MarketPosition.Flat)
      {
      if (position.MarketPosition == MarketPosition.Long)
      {
      ClosingOrder = submissionAccountMaestra.CreateOrder(instrumentSel ectorMaestra.Instrument, OrderAction.Sell, OrderType.Market, OrderEntry.Automated, TimeInForce.Day, position.Quantity, 0, 0, string.Empty, "MANUAL CLOSE", Globals.MaxDate, null);
      submissionMasterAccount.Submit(new[] { ClosingOrder });
      }
      if (position.MarketPosition == MarketPosition.Short)
      {
      ClosingOrder = submissionAccountMaestra.CreateOrder(instrumentSel ectorMaestra.Instrument, OrderAction.Buy, OrderType.Market, OrderEntry.Automated, TimeInForce.Day, position.Quantity, 0, 0, string.Empty, "MANUAL CLOSE", Globals.MaxDate, null);
      submissionMasterAccount.Submit(new[] { ClosingOrder });
      }
      }
      }
      I have this close button to which I want to add if (position.MarketPosition == MarketPosition.Flat)
      close all open orders​​

      Comment


        #4
        Replace all that with this,

        Code:
        // instantiate a list of instruments
        Collection<Cbi.Instrument> instrumentsToClose = new Collection<Instrument>();
        
        lock (submissionAccountMaestra.Positions)
        {
            // add instruments to the collection
        ​    foreach (var position in submissionAccountMaestra.Positions)
                if (position.MarketPosition != MarketPosition.Flat)
        ​            instrumentsToClose.Add(position.Instrument);
        }
        
        submissionAccountMaestra.Flatten(instrumentsToClose);
        submissionAccountMaestra.CancelAllOrders(instrumentsToClose);
        ​

        Comment


          #5
          ok gracias

          Comment


            #6
            Thanks for this code sample.

            Comment


              #7
              Hey there! Wondering if anyone knows how to access the close button on the trade chart through addons? Thinking of creating a panic button feature! If you're into exploring new possibilities, check out https://omegle.fm/ for some fresh experiences!​
              Last edited by AuroraForbes; 04-28-2024, 06:03 PM.

              Comment


                #8
                Hello AuroraForbes,

                Welcome to the NinjaTrader forums!

                Accessing the Close button and invoking this directly would not be directly supported by NinjaTrader (but is possible).

                Instead we would suggest that you use an Account object to call <Account>.Flatten() as suggested in this forum thread, or submit orders to close the position with <Account>.Submit() and cancel orders with <Account>.Cancel().


                Chelsea B.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                593 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                343 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                103 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                556 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                554 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X