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

AtmStrategyCreate and multi-instrument strategy

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

    AtmStrategyCreate and multi-instrument strategy

    Hi,

    when working with AtmStrategyCreate in the strategy that uses several instruments I'm experiencing sporadic submits of the orders for the wrong BarsInProgress.

    You can see it on the attached screenshots of the chart and orders tab.

    There is "if (BarsInProgress != 0) return;" in the strategy's OnBarUpdate() - see code attached.

    Am I doing something wrong?
    Attached Files

    #2
    Hello glivv,

    Thank you for the post.

    I am getting expected results from the strategy you posted. The strategy only places orders to the primary bars series.

    How are you testing this strategy so that I may replicate your environment as closely as possible? Please provide the bar type and period of the primary series and let me know if you are testing this through the playback connection or through live data. It looks like the instrument for the primary series is the FDAX. Please confirm this as well.

    I look forward to your reply.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Strategy trades mostly ok but sometimes orders are placed at YM or NQ (secondary series) which results in order rejects ("order can't be placed above or below market" error).

      Primary series is 10-range of FDAX 03-19 (you can see it on screesnhot). I'm testing it on the live data (iqFeed if that matters).

      Comment


        #4
        Hello glivv,

        Thanks for the reply.

        I will continue to monitor the strategy throughout today. I would recommend adding a redundant bar check, even though

        if (BarsInProgress != 0)
        return;

        should be blocking the other bars series from being called.

        e.g.

        Code:
         if(BarsInProgress == 0)
                    {
                        AtmStrategyCreate(    action, ot, 0, price, TimeInForce.Gtc, atmStrategyOrderId, ATMTemplate, atmStrategyId,
                                        (atmCallbackErrorCode, atmCallbackId) => {
                                            if (atmCallbackId == atmStrategyId) {
                                                if (atmCallbackErrorCode == Cbi.ErrorCode.NoError) {
                                                    atms.Add(atmStrategyId);
                                                    atmorder.Add(atmStrategyId, atmStrategyOrderId);
                                                }
                                            }
                                        });
                    }
        This will ensure the code will not be run unless OnBarUpdate is processing the primary series.

        I look forward to assisting further.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          I've added BIP check as you suggested ("code" screenshot) but it didn't help.

          Today there were plenty of wrong orders. As strategy places market orders when market is near stop price, even wrong position was opened.
          Attached Files

          Comment


            #6
            Screenshots of log tab.
            Attached Files

            Comment


              #7
              Hello glivv,

              Thank you for your reply.

              I have not received this problem while running the script you posted yesterday. Are you seeing this behavior on the test script or the non-stipped down version?

              If you are using the real script, I would like to test that one as well. You may post it here or send it into platfrormsupport[at]ninjatrader[dot]com and paste the link to this forum thread in the body of the email.

              I look forward to your reply.
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                I'm seeing this on the test script - see strategies screenshot, "strippeddown" strategy is running.

                Comment


                  #9
                  Hello glivv,

                  Thank you for the reply.

                  Please take the steps below to reset your database and clear the trade history:
                  • Disconnect NinjaTrader from any open connections via Connections > Disconnect
                  • From the NinjaTrader Control Center window select the menu Tools > Database Management
                  • Click "Reset DB"
                  • Check Historical Orders
                  • Check Historical Trades
                  • Click the "Reset" button
                  Please test your strategy again after this. Please also let me know how you are applying the strategy: through a chart or through the Control Center strategies tab.

                  I look forward to hearing of your results.
                  Chris L.NinjaTrader Customer Service

                  Comment


                    #10
                    I made a DB reset (I assume "Historical Executions" is what you meant by "Historical Trades") and restarted after that.

                    I'm running strategy via chart.

                    Resetting didn't help - see screenshot.
                    Attached Files

                    Comment


                      #11
                      Trade on wrong bars.
                      Attached Files

                      Comment


                        #12
                        Hello glivv,

                        Thank you for your patience.

                        I just received the error while running the strategy live. I will continue to look into the script for the issue.

                        I look forward to assisting further.
                        Chris L.NinjaTrader Customer Service

                        Comment


                          #13
                          Hello glivv,

                          Thank you for your patience.

                          This problem seems to be related to the fact that ATM's are created and submitted on a different thread. I will report this to our product management team to see about implementing a fix for this/a workaround. In the meantime, you may use the Addon approach to use ATM's in your Strategy. This example is somewhat hard to digest since it is so large, but you can place the same logic within a strategy as they do in the Addon framework example to use ATM strategies for orders. See below for the download link:



                          I look forward to assisting further.

                          Chris L.NinjaTrader Customer Service

                          Comment


                            #14
                            Helo Chris,

                            thanks for the info, could you please post when fix or workaround is implemented?

                            Right now strategy is recoded as a full auto, with simple exit management. Using Addon framework is an overkill IMHO.

                            Comment


                              #15
                              Hello glivv,

                              Thanks for your reply.

                              I will update this forum post once I have more information on this. I haven't confirmed it as a bug yet, so there might still be a workaround.

                              Thanks in advance for your patience.
                              Chris L.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by kempotrader, Today, 08:56 AM
                              0 responses
                              7 views
                              0 likes
                              Last Post kempotrader  
                              Started by kempotrader, Today, 08:54 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post kempotrader  
                              Started by mmenigma, Today, 08:54 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post mmenigma  
                              Started by halgo_boulder, Today, 08:44 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post halgo_boulder  
                              Started by drewski1980, Today, 08:24 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post drewski1980  
                              Working...
                              X