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

Indicator + Add-on vs. a Strategy

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

    Indicator + Add-on vs. a Strategy

    Hi,

    I've just become aware that add-ons can do some order management. I've been thinking about developing a strategy, but me preference would be to use a custom indicator. Indicators, as far as I can see, can't do much with placing and managing orders, other than using OIF files. Assuming I were happy with using OIF files to place orders, would an add-on be able to detect whether or not the order were filled after one bar and cancel it if it were not? Part of the challenge is that, for whatever reason, when I create instances of the indicators I'm interested using in my strategy code, the values are not the same as they are when I plot the indicator. I've checked the parameters several times to make sure they are the same.

    Side question - how much latency does using OIF files vs. an API call add to placing an order? I have a fast (new) computer with a new SSD drive. I'm trying to figure out if it
    s a little slower, five times slower, ten times slower, etc. Thanks,

    Gordon

    #2
    Hello grose,

    Using OIF inside NinjaScript is not a good approach, you can just use the existing NinjaScript ways to place orders instead. OIF is for external software.

    If you wanted to place orders from a different type like an indicator or addon you can just use the addon framework for that purpose. You would need to find an account and then use its Submit method. This is shown in the helpguide here: https://ninjatrader.com/support/help...ount_class.htm
    The sample in the above link for finding the account can be used from indicators, you can also subscribe to the accounts order events.


    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      Thank you. It sounds like you can do some order management from within an indicator. I was not aware of that. Do you happen to have any examples of working with orders in an indicator and/or an add-on? If I didn’t have to write an add-on, that would be ideal.

      Regards,

      Gordon

      Comment


        #4
        Hello grose,

        You can see the addon sample for working with orders in an addon, the Account related tasks would apply to indicators but that sample is very complex and most of the code shown will not apply to an indicator. You can instead review the help guide individualized samples for more straightforward examples that can be used in an indicator for account related tasks.

        https://ninjatrader.com/support/help...t_overview.htm addon sample basic shows all addon concepts in a new window




        The addon help guide section contains stripped down samples of each concept, you just need to click on the topic like Account. Under the Account section you will find other sub topics like Submit and Change, Cancel etc. The Account main page has a sample that demonstrates Finding the account and subscribing to the order events which is required for nearly all the other sub pages. You will need to have found the account and stored it to a variable to use the Submit page sample as an example.

        https://ninjatrader.com/support/help...ount_class.htm find the account, that code could be copied directly into an indicator as it uses OnStateChange.

        https://ninjatrader.com/support/help...nt8/submit.htm How you would create an order and submit it, you would use this type of logic in a condition to place an order in your OnBarUpdate logic. It references the account you found in the Account sample.

        Please let me know if I may be of additional assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse,

          Thank you. I'm returning to this after a bit. It appears than add-on can be windowless and can also modify a chart window. Just in basic terms, is it possible for an add-on to add a button to the toolbar of an existing chart? It's through the code associated with that button that I would want to execute order logic, such as https://ninjatrader.com/support/help...tmstrategy.htm. If you are aware of such an example, it would be a great head start.

          I'd ideally like to enter orders directly from indicator code without having to write an add-on - then I could associate the order with the location of the mouse and a specific key combination, such as Ctrl-UpArrow for very rapid processing. Is that doable that you are aware of?

          Regards,

          Gordon

          Comment


            #6
            Hello grose,

            Yes that is possible, you could use the OnWindowCreated override to find the various windows when they are opened. If you have reviewed any other indicator sample which modifies the chart you will see that the chart window is found and used, the same concept would apply in an addon you just find the window using OnWindowCreated. There are some situations where you may want to modify all windows or existing open widows, in that case you can use the NinjaTrader.Core.Globals.AllWindows collection. There are a lot of samples in the following post for modifying a chart window, you could still use those concepts from an addon as noted finding the chart window would just be done using the OnWindowCreated or AllWindows collection.
            Hello All, Moving forward this will be maintained in the help guide reference samples and no longer maintained on the forum. Creating Chart WPF (UI) Modifications from an Indicator - https://ninjatrader.com/support/help...ui)-modifi.htm (https://ninjatrader.com/support/helpGuides/nt8/creating-chart-wpf-(ui)-modifi.htm) I've




            Please let me know if I may be of additional assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by f.saeidi, Today, 10:19 AM
            0 responses
            2 views
            0 likes
            Last Post f.saeidi  
            Started by kujista, Today, 06:23 AM
            4 responses
            14 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by traderqz, Yesterday, 09:06 AM
            2 responses
            16 views
            0 likes
            Last Post traderqz  
            Started by traderqz, Today, 12:06 AM
            3 responses
            6 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by RideMe, 04-07-2024, 04:54 PM
            5 responses
            28 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Working...
            X