Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how to press Buy Ask, Sell Bid buttons in Ninjascript?

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

    how to press Buy Ask, Sell Bid buttons in Ninjascript?

    are there any examples?

    do I need to get the Automation ID? (examples?)

    thx

    #2
    Hello llanqui,

    Thank you for your post.

    It is possible to do this but unfortunately requires unsupported code.

    We suggest you can instead submit a limit order at the ask or bid through the Account object, and you can attach and ATM strategy if desired.

    Account object - https://ninjatrader.com/support/help...gy_account.htm
    Account class - https://ninjatrader.com/support/help...ount_class.htm
    CreateOrder - https://ninjatrader.com/support/helpGuides/nt8/createorder.htm
    Submit - https://ninjatrader.com/support/help...nt8/submit.htm
    GetCurrentAsk - https://ninjatrader.com/support/help...currentask.htm
    AtmStrategyCreate - https://ninjatrader.com/support/help...tegycreate.htm


    Please let me know if you have any other questions.

    Comment


      #3
      yes, I can do that, but probably it adds a few milliseconds ... :-)

      I have to gather the charttrader values, build the order, and submit it...when the buttons will do that all for me and faster I imagine


      the GetCurrentAsk / GetCurrentBid .... what thread do those operate in? OnBarUpdate, OnMarketData?

      If I do you you say I need the immediate last bid or ask...perhaps I should get it from OnMarketData?

      on the original question...I found these in one of your samples...that will give me a start if I want to press the button, I imagine cause I can get the button handle this way it appears (assuming they are named similar)

      // chartWindow = System.Windows.Window.GetWindow(ChartControl.Paren t) as NinjaTrader.Gui.Chart.Chart;
      // chartTraderGrid = (Window.GetWindow(ChartControl.Parent).FindFirst(" ChartWindowChartTraderControl") as ChartTrader).Content as System.Windows.Controls.Grid;
      // buyMarketButton = chartTraderGrid.FindFirst("ChartTraderControlQuick BuyMarketButton") as System.Windows.Controls.Button;
      // sellMarketButton = chartTraderGrid.FindFirst("ChartTraderControlQuick SellMarketButton") as System.Windows.Controls.Button;

      Comment


        #4
        Hello,

        Invoking a button click is not officially supported by NinjaTrader. We would suggest using the documented and supported method of sending the order through the account. The account can be cached when the script starts, and the amount of time to create the order and submit it would be the same (possibly slightly faster since the click method does not have to run through).

        That said, if you intend to use unsupported code, do a search for invoking a button click.

        https://www.google.com/search?q=c%23...e+button+click

        Yes, ChartTraderControlQuickBuyAskButton and ChartTraderControlQuickBuyBidButton would be the proper AutomationIDs for these buttons.

        Please let us know if you have any further questions.

        Comment


          #5
          thanks, yes, not so complicated

          I choose button.PerformClick()



          but just curious...GetCurrentBid /Ask I think is refreshed in the OnBarUpdate thread....

          is this true: so the only way that it would be current is if OnBarUpdate was at the per tick level?

          Comment


            #6
            Hello,

            GetCurrentAsk()/Bid() can be used in any method at any time in real-time. It's not a series that is data driven, but a method that retrieves a snapshot of the current ask and bid directly from the feed.

            Please let us know if you have any other questions.

            Comment


              #7
              OK, thank you

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              605 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              351 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              105 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              560 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              561 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X