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

ATM in strategy works once then no further trades are taken.

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

    ATM in strategy works once then no further trades are taken.

    I've been trying to get ATM to work in the attached script. With ATM enabled, it will take one trade and then no more after that. I've tried to troubleshoot but I am still missing something as far as managing the ATM. I would appreciate any suggestions to get the ATM function working properly. SkyFireATM1.1.cs

    #2
    Hello geddyisodin,

    Thank you for your post.

    Are you getting any errors in the Log tab of the Control Center?

    I see you are using both Enter/Exit methods as well as AtmStrategy methods in your script, are you saying your AtmStrategy is not taking further trades or the strategy itself is not executing trades?

    I look forward to assisting further.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the support, Gabe. If I enter an ATM strategy name when running the strategy, it will make 1 trade with the ATM and then won't take any more trades. I do not see any errors in the log, just tried it again to confirm and it's exhibiting the same behavior.
      Last edited by geddyisodin; 04-25-2024, 08:47 AM.

      Comment


        #4
        Hello geddyisodin,

        Thank you for your response.

        To understand why the script is behaving as it is, such as placing orders or not placing orders or drawing objects when expected, it is necessary to add prints to the script that print the values used for the logic of the script to understand how the script is evaluating.

        In the strategy add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition that places an order.

        The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.

        I also recommend using the methods in the ATM Strategy Monitoring section of the Atm Strategy Methods to get info about orders placed using Atm Strategies, such as GetAtmStrategyEntryOrderStatus().





        The SampleAtmStrategy sample that comes with NinjaTrader demonstrates using some of those methods for monitoring orders submitted using Atms.

        Prints will appear in the NinjaScript Output window (New > NinjaScript Output window).

        Please let me know if I may further assist with analyzing the output or if you need any assistance creating a print.​​
        Gaby V.NinjaTrader Customer Service

        Comment


          #5
          Is there a way to get more detail on the error?
          ATM Strategy Long Started: MyAtmStrategyLong

          Last Trade: +1 Standard Buy at 17457

          ATM Strategy Error: MyAtmStrategyLong

          ATM Strategy Long Started: MyAtmStrategyLong

          Last Trade: +1 Standard Buy at 17458.75

          ATM Strategy Error: MyAtmStrategyLong

          ATM Strategy Short Started: MyAtmStrategyShort

          Last Trade: -1 Standard Sell at 17457.5

          ATM Strategy Error: MyAtmStrategyShort

          Comment


            #6
            Hello geddyisodin,

            Thank you for your reply.

            Where are you seeing these error messages, in the output or in the Log? Can you provide the full error message?

            Thanks in advance.
            Gaby V.NinjaTrader Customer Service

            Comment


              #7
              Hi Gabe,
              This is what I added for ATM Long. I am seeing those errors in the output but it doesn't give any further info.

              if (xy.Contains("+1") && (Position.MarketPosition != MarketPosition.Short))

              {

              if (dailyPnL > -DailyLossLimit && dailyPnL < DailyProfitLimit)

              {

              if (iOpenPositions < iMaxContracts)

              {

              // Start the ATM strategy for a long position

              AtmStrategyCreate(

              OrderAction.Buy, OrderType.Market, 0, 0, TimeInForce.Day,

              GetCurrentAsk().ToString(), "MyEntryLong", "MyAtmStrategyLong",

              (errorCode, errorMessage) =>

              {

              if (errorCode != ErrorCode.NoError)

              Print("ATM Strategy Error: " + errorMessage);

              });




              Print("ATM Strategy Long Started: MyAtmStrategyLong");

              sLastTrade = xy + " at " + GetCurrentAsk();

              Print("Last Trade: " + sLastTrade);

              }

              else

              {

              Print("Max Contracts Reached: " + iMaxContracts);

              }

              }

              }

              Comment


                #8
                Hello geddyisodin,

                Unfortunately no, the most you could print out is the error code. Try printing out the error code, what code are you getting?

                I would expect that if the Atm strategy is getting an error on being created, an error message would pop up in the Log. Can you double check there are no error messages in the Log?
                Gaby V.NinjaTrader Customer Service

                Comment


                  #9
                  Hello geeddyisodin,

                  Did you add the prints to debug the code? Without the output from the prints, there is no information to make an educated guess about what could be going on.

                  In the strategy add prints (outside of any conditions) that print the date time of the bar and all values compared in every condition that places an order.

                  The prints should include the time of the bar and should print all values from all variables and all hard coded values in all conditions that must evaluate as true for this action to be triggered. It is very important to include a text label for each value and for each comparison operator in the print to understand what is being compared in the condition sets.​
                  I'm not seeing in your code prints as described above. I'm only seeing non-descriptive prints added inside the conditions. They should be outside the conditions so we can see why the conditions are not evaluating as true.

                  Additionally, were you able to print out the error code or double-check if you are getting any errors in the Log tab of the Control Center?
                  Last edited by NinjaTrader_Gaby; 04-26-2024, 10:51 AM.
                  Gaby V.NinjaTrader Customer Service

                  Comment


                    #10
                    I'm all set now, went back to the sample ATM strategy and was able to lift enough to fix it. Thanks!

                    Comment


                      #11
                      Hi @geeddyisodin, I'm having the exact same issue. Can you tell me what the problem was? Thanks.

                      Comment


                        #12
                        Never mind... I figured it out. The variables containing the orderid weren't resetting.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by PhillT, 04-19-2024, 02:16 PM
                        4 responses
                        30 views
                        0 likes
                        Last Post PhillT
                        by PhillT
                         
                        Started by ageeholdings, 05-01-2024, 05:22 AM
                        5 responses
                        36 views
                        0 likes
                        Last Post ageeholdings  
                        Started by reynoldsn, Today, 02:34 PM
                        0 responses
                        7 views
                        0 likes
                        Last Post reynoldsn  
                        Started by nightstalker, Today, 02:05 PM
                        0 responses
                        14 views
                        0 likes
                        Last Post nightstalker  
                        Started by llanqui, Yesterday, 09:59 AM
                        8 responses
                        30 views
                        0 likes
                        Last Post llanqui
                        by llanqui
                         
                        Working...
                        X