Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Can't figure out right variable for GetAtmStrategyMarketPosition("atmStrategyId")

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

    #16
    Cody I am going to get that screen shot for you tomorrow. As I watched the script trade today there was another anomaly that I found maybe you can comment on. The script trades on an NQ chart as the primary. I've added the following object in the Initialize section:

    Add("^TICKQ", PeriodType.Minute, 1).

    It is the first object added. Other objects have been added but they are just different time periods of the NQ.

    In my strategy a condition to entering a trade long or short is that the ^TICKQ must be at a certain level to enter the trade. For example, to enter short the ^TICKQ must be below -275. This is represented in the Code by the following line

    && Closes[1][0]<-275

    Today I ran the strategy with COBC=True. Accordingly, I would assume that it would only enter a trade if the one minute Tick closed at <-275. Attached you will see a picture of the NQ chart with the ^Tickq added as a data series.You can see that an alert and trade was entered into at 15:59. However, on that period, the ^TICKQ closed at +91 well above the -275 threshold. There were actually several trades like that today where the close of the ^TICKQ did not meet the threshold of the trade entry and yet the trade still executed. Here is the other interesting component. If I shut the strategy down and restart it. Those anamolous trade signals don't show up and the only trade signals on the chart are where the ^TICKQ did meet the threshold for entry.

    Any ideas on this issue (actually not sure how to upload an image-will do it tomorrow)

    Comment


      #17
      Here is the attachment
      Attached Files

      Comment


        #18
        Hello,
        This could be do to something with the logic of the code. I would recommend to use the Print method and review the statements to debug this. You would want to print out all of what could make the conditions true and examine these Prints and then change the logic based off of them. I would also recommend printing out the time that the trade was submitted. As working with CalculateOnBarClose = True if you get submit an order on a bar it would appear on the next bar as the code is all ran at the end of the bar.
        Please see the following link on Print() method: http://ninjatrader.com/support/helpGuides/nt7/print.htm
        I would also recommend reviewing the following video on using the Print() method: https://www.youtube.com/watch?v=K8v_...tu.be&t=48m35s
        Cody B.NinjaTrader Customer Service

        Comment


          #19
          Thanks cody Ill look at that so you are saying the trade signal may be "printed" over the bar after the bar where the condition set was true is that correct?

          also attached are the screen shots we discussed yesterday involving the multiple orderrs
          Attached Files

          Comment


            #20
            Hello,
            Yes the trade would have been placed on the next bar. The print would show this if you print out the time of the signal and the time the order was placed.

            Are you receiving the same behavior after implementing my suggested logic?
            Cody B.NinjaTrader Customer Service

            Comment


              #21
              Well, I gave it a try by basically placing the sample code into my script and that didn't work too well. I'm not getting any signals now. I will continue to play with it and see if I get anywhere. This is very daunting for someone who has never programmed before. It is however enjoyable to try and learn how to do it. Frustrating but enjoyable. At least for me.

              Comment


                #22
                One thing that is confusing to me is the following quote:

                Thus we have and orderId.length that is greater than 0, and atmStrategyId.length that is greater than 0 and a position that is flat thus, the atmStrategyId and orderId are reset and begins the process of submitting the order again and the cycle repeats.


                Why wouldn't you want both the OrderId and the atmStrategy to =0 and the market to be flat before resetting those to items. Don't you want there to be no orders pending before there is another order sent.

                Comment


                  #23
                  EnterLongStop

                  EnterLongStop(DefaultQuantity, Close[0] + 2 * TickSize, "LongUpBar+2");
                  I understand that this script above will signal an entry if price exceeds Close[0] by +2, but it will only signal if the +2 occurs during Close[0]. I want to create a script that will signal an entry if price doesn't exceed Close[0] by +2 for several bars (say seven) and then does exceed Close[0] by +2 on the eighth bar. Can you help me? Thank you.

                  Comment


                    #24
                    Cody going back to the Tick issue i added the following to my code to get a reading on the Tick value.

                    Print(Time[0].ToString()+ "-" +Closes[1][0].ToString());

                    Now this is a strategy that is COBC=True so I was assuming I would get one number back on the close of each bar. Here is a snipit however of what I received however in the output window:

                    1/28/2016 3:26:00 PM-146
                    1/28/2016 3:26:00 PM-146
                    1/28/2016 3:26:00 PM-146
                    1/28/2016 3:26:00 PM-146
                    1/28/2016 3:26:00 PM-3
                    1/28/2016 3:26:00 PM-3
                    1/28/2016 3:26:00 PM-3
                    1/28/2016 3:26:00 PM-3
                    1/28/2016 3:27:00 PM-3
                    1/28/2016 3:27:00 PM-3
                    1/28/2016 3:27:00 PM-154
                    1/28/2016 3:27:00 PM-154
                    1/28/2016 3:27:00 PM-154
                    1/28/2016 3:27:00 PM-154
                    1/28/2016 3:28:00 PM-154
                    1/28/2016 3:28:00 PM-154
                    1/28/2016 3:28:00 PM-154
                    1/28/2016 3:28:00 PM-154
                    1/28/2016 3:28:00 PM--294
                    1/28/2016 3:28:00 PM--294
                    1/28/2016 3:28:00 PM--294
                    1/28/2016 3:28:00 PM--294
                    1/28/2016 3:29:00 PM--294
                    1/28/2016 3:29:00 PM--294
                    1/28/2016 3:29:00 PM-74
                    1/28/2016 3:29:00 PM-74
                    1/28/2016 3:29:00 PM-74
                    1/28/2016 3:29:00 PM-74


                    As you can see there are multiple values assigned to the Tick for any given minute. 3:26 for example has values from 146 to 3. 329 has values from 294 to 74. One of the numbers is generally the correct value for the close of the period. It is effecting the order entry because there are orders being places where the Tick threshold in the strategy is not being met.

                    Thanks again.

                    Comment


                      #25
                      Hello mdb4403 ,

                      Originally posted by mdb4403 View Post
                      One thing that is confusing to me is the following quote:

                      Thus we have and orderId.length that is greater than 0, and atmStrategyId.length that is greater than 0 and a position that is flat thus, the atmStrategyId and orderId are reset and begins the process of submitting the order again and the cycle repeats.


                      Why wouldn't you want both the OrderId and the atmStrategy to =0 and the market to be flat before resetting those to items. Don't you want there to be no orders pending before there is another order sent.
                      If the atmStrategyId.Legth is = 0 this means that there is not an atmStrategyId to check's position. This is where you would reset. This is showing that there was an orderId with an atmStrategy and that position is not flat so you could then reset the atmStrategyId and OrderId to 0 so that they do not reference an order or atm strategy and can be used again.

                      In regards to your matter with the TICKQ when you ran this was this ran on a minute chart?
                      Cody B.NinjaTrader Customer Service

                      Comment


                        #26
                        Yes it was a 1 minute chart and the Object that was added was the 1 minute Tickq

                        Comment


                          #27
                          Hello paunic305,
                          To keep a good order to the forum and its threads we do ask that new questions to be created as their own thread and not added to a post unless it is dealing with the same issue.

                          Can you clarify further what you are looking to accomplish? Perhaps do you have an image of a chart that illustrates this?
                          Cody B.NinjaTrader Customer Service

                          Comment


                            #28
                            Hello,
                            How many added data series do you have? If you have multiple ones it will print out on each of the data series bar update.
                            Please add the following for the print:
                            Code:
                            if(BarsInProgress ==  1)
                                Print(Time[0].ToString() + "-" + Closes[1][0].ToString());
                            Do you see multiple prints for the same minute with this instead?

                            For more information on BarsInProgress please see the following link: http://ninjatrader.com/support/helpG...inprogress.htm
                            Cody B.NinjaTrader Customer Service

                            Comment


                              #29
                              I do have multiple time series. I will give that a try tomorrow. Fascinating this whole programming thing.

                              Comment


                                #30
                                Could the fact that I have multiple times series be What is causing the problem that I see with the strategy entering trades with the tick threshold is not met

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                                0 responses
                                574 views
                                0 likes
                                Last Post Geovanny Suaza  
                                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                                0 responses
                                333 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by Mindset, 02-09-2026, 11:44 AM
                                0 responses
                                101 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                                0 responses
                                553 views
                                1 like
                                Last Post Geovanny Suaza  
                                Started by RFrosty, 01-28-2026, 06:49 PM
                                0 responses
                                551 views
                                1 like
                                Last Post RFrosty
                                by RFrosty
                                 
                                Working...
                                X