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

Getting Current Ask in an Addon

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

    Getting Current Ask in an Addon

    I'm unable to resolve a compilation error on the SubmitBuyLimitOrderWithAtmAddonNoTabsExample Addon and as follows;

    Order buyLimitOrder = accountSelector.SelectedAccount.CreateOrder(atmStr ategySelector.Instrument, OrderAction.Buy, OrderType.Limit, TimeInForce.Gtc, 3, <GetCurrentAsk>, 0, string.Empty, "Entry", null);

    What should <GetCurrentAsk> be ?

    I successfully used GetCurrentAsk() in the SampleWPFModifications Indicator example and as follows;

    entryOrder = myAccount.CreateOrder(myInstrument, OrderAction.Sell, OrderType.Limit, OrderEntry.Manual, TimeInForce.Gtc, 3, GetCurrentAsk() + 15 * TickSize, 0, "", "Entry", Core.Globals.MaxDate, null);

    However, the GetCurrentAsk() does not work on the SubmitBuyLimitOrderWithAtmAddonNoTabsExample Addon ... the error messages are; "The name 'GetCurrentAsk' does not exist in the current context' and "The name 'TickSize' does not exist in the current context".

    Please, I shall appreciate any tips and guides.


    Omololu

    #2
    Hello omololu, thanks for your post. It looks like this was already asked this on a separate thread from earlier:

    https://ninjatrader.com/support/foru...e2#post1128290

    Our colleague Chelsea will follow up on that thread.

    In an addon, it is necessary to subscribe to the market data that is needed. The addon example that we have has an example of doing this:

    https://ninjatrader.com/support/help...t_overview.htm

    Best regards,

    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChrisL View Post
      Hello omololu, thanks for your post. It looks like this was already asked this on a separate thread from earlier:

      https://ninjatrader.com/support/foru...e2#post1128290

      Our colleague Chelsea will follow up on that thread.

      In an addon, it is necessary to subscribe to the market data that is needed. The addon example that we have has an example of doing this:

      https://ninjatrader.com/support/help...t_overview.htm

      Best regards,

      -ChrisL
      Hello Chris,

      Please, disregard my post in the other earlier thread considering that the issue in the thread is about GetCurrentAsk()/GetCurrentBid().

      I seem to be comfortable with GetCurrentAsk()/GetCurrentBid() and as used in the SampleWPFModifications Indicator example. Also, and as stated in my post #1 above, I have successfully used GetCurrentAsk() in the SampleWPFModifications Indicator example.

      I'm having issue with the code for getting current Ask/Bid price in the SubmitOrderWithAtmAddonNoTabsExample Addon, and similar to GetCurrentAsk()/GetCurrentBid(). You will please note that the SubmitOrderWithAtmAddonNoTabsExample Addon showed only example of Market Buy/Sell Order entry (i. e. Order buyOrder = accountSelector.SelectedAccount.CreateOrder(atmStr ategySelector.Instrument, OrderAction.Buy, OrderType.Market, TimeInForce.Gtc, 3, 0, 0, string.Empty, "Entry", null); I want the code for a Limit Buy/Sell (and even StopLimit) Order entry.

      Regards.

      Omololu
      Last edited by omololu; 11-19-2020, 02:37 PM.

      Comment


        #4
        Hello Omololu, thanks for your reply.

        GetCurrentAsk/Bid is part of the NinjaScriptBase class, and strategies inherit from

        Strategy :StrategyRenderBase : StrategyBase : NinjaScriptBase

        So your indicator would need a strategies StrategyBase object to call it's GetCurrentAsk/Bid method. You can do this by implementing a method in the Addon that takes a StrategyBase object, and have the strategy call this method, passing in it's StrategyBase object.

        For a stand-alone, addon-only approach to this, your addon would need to perform a Bars Request and subscribe to market data update events. There is an exact example of doing this on line 773 of the addon example provided in my last reply. Search the string:

        Code:
        // When user presses the Realtime Data button
        if (button != null && ReferenceEquals(button, realtimeDataButton))
        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChrisL View Post
          Hello Omololu, thanks for your reply.

          GetCurrentAsk/Bid is part of the NinjaScriptBase class, and strategies inherit from

          Strategy :StrategyRenderBase : StrategyBase : NinjaScriptBase

          So your indicator would need a strategies StrategyBase object to call it's GetCurrentAsk/Bid method. You can do this by implementing a method in the Addon that takes a StrategyBase object, and have the strategy call this method, passing in it's StrategyBase object.

          For a stand-alone, addon-only approach to this, your addon would need to perform a Bars Request and subscribe to market data update events. There is an exact example of doing this on line 773 of the addon example provided in my last reply. Search the string:

          Code:
          // When user presses the Realtime Data button
          if (button != null && ReferenceEquals(button, realtimeDataButton))
          Please let me know if I can assist any further.
          Thanks Chris for your reply.

          I cannot seem to see any "addon example provided ...". Please, direct me to the Addon again.

          Regards.

          Omololu

          NB: Sorry Chris ... Is it the AddOn Framework NinjaScript Basic zip file ? If Yes, then I already have it on my PC. I've seen the line 773. I'm studying it. Thanks.
          Last edited by omololu; 11-19-2020, 05:02 PM.

          Comment


            #6
            Hi Chris,

            I'm unable to pick any code/script from line 773 of the AddOn Framework NinjaScript Basic add-on that shows an example of my issue. I further studied the bottom of this link here and it seems I can only have e.BarsSeries.GetOpen(i), e.BarsSeries.GetHigh(i), e.BarsSeries.GetLow(i), e.BarsSeries.GetClose(i) and NOTHING on e.BarsSeries.GetAsk(i) or e.BarsSeries.GetBid(i). Please, remember that what I want is to do "Order buyLimitOrder = accountSelector.SelectedAccount.CreateOrder(atmStr ategySelector.Instrument, OrderAction.Buy, OrderType.Limit, TimeInForce.Gtc, 3, <GetCurrentAsk>, 0, string.Empty, "Entry", null)". Line 929 shows how to code Buy Market order; I want to do Buy Limit order. Is there no example code/script that shows exactly this ?

            Regards.

            Omololu

            Comment


              #7
              Hello omololu, thanks for your reply.

              In the addon example, there are many different ways of receiving data. The "SnapShot" button (marketDataSnapshotButton) is likely the one you would want to emulate. The data from here is set in the OnMarketData method of the Instrument. See line 2039 for the start of the Instrument definition, this is where market data is subscribed to the instrument.

              Please let me know if I can assist any further.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_ChrisL View Post
                Hello omololu, thanks for your reply.

                In the addon example, there are many different ways of receiving data. The "SnapShot" button (marketDataSnapshotButton) is likely the one you would want to emulate. The data from here is set in the OnMarketData method of the Instrument. See line 2039 for the start of the Instrument definition, this is where market data is subscribed to the instrument.

                Please let me know if I can assist any further.
                Thanks Chris,

                Yes, your tips and guide have been very useful. However, my attempt to copy and paste those relevant portions of the marketDataSnapshotButton and Instrument definition, threw up some compilation errors. The Add-on that I'm tweaking is the SubmitOrderWithAtmAddonNoTabs that you directed me to a few weeks ago. The SubmitOrderWithAtmAddonNoTabs has provision for Buy Market ONLY. I just want to tweak it to allow me to implement Buy Limit, Sell Limit, and even StopLimit (Buy and Sell). Could you please avail me with the example of how to use the relevant portions of the marketDataSnapshotButton and Instrument definition referred to above, to implement, at least, Buy Limit in the SubmitOrderWithAtmAddonNoTabs Add-on ?

                Best Regards.

                Omololu

                Comment


                  #9
                  Hello omololu, thanks for your reply.

                  I am having trouble locating the example SubmitOrderWithAtmAddonNoTabs that I sent you. It's possible another team member directed you to this example. Could you link me to where this was previously discussed?
                  Chris L.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_ChrisL View Post
                    Hello omololu, thanks for your reply.

                    I am having trouble locating the example SubmitOrderWithAtmAddonNoTabs that I sent you. It's possible another team member directed you to this example. Could you link me to where this was previously discussed?
                    Thanks Chris,

                    It is here. As you will note, this example only shows Buy Market order as follows and in lines 117 & 118;

                    Order buyMar****rder = accountSelector.SelectedAccount.CreateOrder(atmStr ategySelector.Instrument, OrderAction.Buy, OrderType.Market, TimeInForce.Day, 1, 0, 0, string.Empty, "Entry", null);
                    NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrate gy(atmStrategySelector.SelectedAtmStrategy, buyMar****rder);

                    I want to tweak it to allow me to implement Buy Limit, Sell Limit, and even StopLimit (Buy and Sell) orders

                    Please, have a look at my earlier request on this ad-don here.

                    Omololu
                    Last edited by omololu; 11-23-2020, 05:35 PM.

                    Comment


                      #11
                      Hello omololu thanks for your reply.

                      Unfortunately, I am not able to make any further changes to the already existing examples we have. The addon framework example demonstrates many things that can be done with an addon and will be the best resource to study. For more practice working with Bars Requests and getting an OnMarketData stream from an instrument, consider making a new addon that only implements the "Data Access" section of the addon framework example. Then you could implement order submission behavior based around the working code rather than fitting the addon examples code around an order submission button.

                      Kind regards,
                      -ChrisL
                      Chris L.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by RideMe, 04-07-2024, 04:54 PM
                      5 responses
                      28 views
                      0 likes
                      Last Post NinjaTrader_BrandonH  
                      Started by f.saeidi, Today, 08:13 AM
                      1 response
                      4 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by DavidHP, Today, 07:56 AM
                      1 response
                      5 views
                      0 likes
                      Last Post NinjaTrader_Erick  
                      Started by kujista, Today, 06:23 AM
                      3 responses
                      9 views
                      0 likes
                      Last Post kujista
                      by kujista
                       
                      Started by Mindset, Yesterday, 02:04 AM
                      2 responses
                      18 views
                      0 likes
                      Last Post NinjaTrader_RyanS  
                      Working...
                      X