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

StartAtmStrategy in AddOn Shows State "Initialized"

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

    StartAtmStrategy in AddOn Shows State "Initialized"

    I am using the StartAtmStrategy in an AddOn. When the method is executed, the submitted order state is set to "Initialized" and the order is never triggered when the price is touched.

    Click image for larger version  Name:	2021-01-28 11_43_13-Control Center - Orders.png Views:	0 Size:	3.0 KB ID:	1138785

    I can submit the same order using Account.Submit and it works correctly.

    Code:
    Order order = orderParameters.Account.CreateOrder(
       orderParameters.Instrument, orderAction, orderType,
       OrderEntry.Manual, orderParameters.TimeInForce,
       orderParameters.Quantity, limitPrice, stopPrice,
       ocoId, orderName, goodTillDate, null);
    
    if(orderParameters.ATMStrategy == null)
       orderParameters.Account.Submit(new[] { order });
    else
       AtmStrategy.StartAtmStrategy(orderParameters.ATMStrategy, order);
    I've tried setting the ATM Strategy 2 different ways and both result in the same "Initialized" state.
    Code:
    AtmStrategySelector atmStrategySelector = ChartTrader.FindFirst(CHART_TRADER_ATM_STRATEGY_SELECTOR) as AtmStrategySelector;
    orderParameters.ATMStrategy = atmStrategySelector.SelectedAtmStrategy;
    Code:
    Chart chartWindow = window as Chart;
    orderParameters.ATMStrategy = chartWindow.ChartTrader;.AtmStrategy;
    Any ideas what I might be doing wrong?

    Thanks, Greg
    The Trading Mantis
    NinjaTrader Ecosystem Vendor - The Trading Mantis

    #2
    Hello gregschr,

    Thank you for the post.

    Could you try using the ATM submission from the Sample Addon? That also uses StartAtmStrategy with the selected ATMStrategy object. https://ninjatrader.com/support/help...t_overview.htm

    Another item to try would be to make a different template to check if this somehow relates to the settings used in the template.

    If you see that you can replicate this with the sample addon, could you provide the template you are using so I could test this on my end?
    Documents\NinjaTrader 8\templates\AtmStrategy


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      Thanks for the quick response!

      I tried another ATM strategy by creating a very simple strategy. That one also has the same issue.
      Click image for larger version

Name:	2021-01-28 13_26_35-Chart - MES 03-21 1 Minute.png
Views:	220
Size:	13.2 KB
ID:	1138799

      It looks like StartAtmStrategy is only used in the compiled AddOn, not the Basic AddOn Framework. I'll get the dll created and let you know what I find.

      Thanks, Greg
      The Trading Mantis
      NinjaTrader Ecosystem Vendor - The Trading Mantis

      Comment


        #4
        Hello gregschr,

        Thank you for the reply.

        The Sample addon basic also contains the StartAtmStrategy, its on line 930. You would need to use that tool similar to the chart trader and first select a strategy using the ATM selector and then submit an entry order.


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hi Jesse,

          Just used the compiled AddOn Framework. Nice that the solution post-build commands are included to copy the dll's to the correct directory.

          I tested the Framework with both ATM Strategies and they both work correctly. I'm going to compare the code in my AddOn and the Framework AddOn to see what the Framework is doing differently.

          Will let you know what I find.

          Thanks, Greg
          The Trading Mantis
          NinjaTrader Ecosystem Vendor - The Trading Mantis

          Comment


            #6
            Hi Jesse,

            Yeah, when I search for the StartAtmStrategy in the Basic AddOn, it helps if I spell what I am searching for correctly.

            Anyway, I also ran the Basic AddOn, and it also works correctly for both ATM Strategies.

            I took a look at the code in the AddOn and I do not see anything that is different from one of the approaches I am tried. The only difference, in my case, is I am accessing the ATM Strategy selector on the Chart Trader because my AddOn adds functionality to the Chart Trader.

            I inspected atmStrategySelector.SelectedAtmStrategy in debug and it is retrieving the correct ATM Strategy. I also compared all the property values of the ATMStrategy at runtime in the both my AddOn and the Framework AddOn. Everything is the same, except for the ATMSelector Guid, which makes sense since the AddOn is using a different selector.

            I did find this post on the forum, SIM trading NQ orders regularly stay 'initialized'. It has a similar issue, only with orders that are directly submitted.

            To see if the issue is just related to the Sim account, I tried on a Live account and have the same issue.

            Edit: Also tried using a couple different instruments and the other StartAtmStrategy overload. Same issue in all cases.

            Any other ideas?

            Thanks, Greg
            Last edited by TheTradingMantis; 01-28-2021, 03:38 PM.
            The Trading Mantis
            NinjaTrader Ecosystem Vendor - The Trading Mantis

            Comment


              #7
              Hello gregschr,

              Thanks for testing that.

              The only other observation I could make here is that potentially the strategy object is not formed corrected for the use case here. Have you tried passing the template name to StartAtmStrategy as a string rather than passing the strategy object? That would make the platforms internal process recreate the strategy which should work.

              I Look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Hi Jesse,

                Your suggestion on using a string rather the strategy object, was the other AtmStartStrategy overload I tested.

                But, I figured out what the problem was.

                The documentation for the AtmStartStrategy says "Critical: The "name" argument on the CreateOrder() method MUST be named "Entry" for the ATM Strategy to be started successfully."

                I updated my code to use that name and it works.

                Since failing to do this causes such an unusual issue and also results in Pending Orders that can only be cleared by Resetting the Database, would it make sense to ask Development to update this method with a guard clause and return an error if the name is something other than "Entry"?

                Thanks, Greg
                Last edited by TheTradingMantis; 01-28-2021, 04:32 PM.
                The Trading Mantis
                NinjaTrader Ecosystem Vendor - The Trading Mantis

                Comment


                  #9
                  Hello gregschr,

                  Thank you for the reply.

                  I don't believe there would be any merit in trying to submit that for changes, its already documented that needs to be done and is in the samples we provide as well. Now that you know the problem it would not come up again in your script so trying to pursue that wouldn't assist here any further. We generally do take in feature requests so I appreciate you asking, this is just a very uncommon item to run into. This would be the type of item that would generally get documented if it comes up and is reported, very likely why the comment is in the help guide at this point.


                  I look forward to being of further assistance.






                  JesseNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by rocketman7, Today, 01:00 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post rocketman7  
                  Started by wzgy0920, 04-20-2024, 06:09 PM
                  2 responses
                  27 views
                  0 likes
                  Last Post wzgy0920  
                  Started by wzgy0920, 02-22-2024, 01:11 AM
                  5 responses
                  32 views
                  0 likes
                  Last Post wzgy0920  
                  Started by wzgy0920, 04-23-2024, 09:53 PM
                  2 responses
                  74 views
                  0 likes
                  Last Post wzgy0920  
                  Started by Kensonprib, 04-28-2021, 10:11 AM
                  5 responses
                  193 views
                  0 likes
                  Last Post Hasadafa  
                  Working...
                  X