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

Variables not uodating after applying ATM order entry code

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

    Variables not uodating after applying ATM order entry code

    Hello!

    so I had a strategy to which worked fine but I wanted it to open orders per a specific ATM. However the moment I migrated the requirements inti the sample ATM templete and had it run live I noticed it would open orders carelessly each bar the conditions are met disregarding the BarsSinceEntry or Exit condition. To debug I set it to print the value of the variables and to my surprise all of them were 0 (not updating at all).I'm not sure what I may be missing since version without ATM works fine

    Working and not working strategies attached as well as required not native indicators

    I'm not to fluent in coding so please be patient if I come up with a few questions after your reply. As well please let me know if I should add more info or another attachment


    #2
    Attachments
    Attached Files

    Comment


      #3
      Hello OsvaldoVision,

      Thanks for your post.

      ATM strategies that are initiated from NinjaScript strategies are separate strategies. The NinjaScript strategy does not have any inherent knowledge of the ATM strategy's position. ATM strategy positions would belong to the ATM strategy while the NinjaScript strategy peeks or manipulates the strategy using the ATM Strategy methods. BarsSinceEntryExecution and other methods of the managed approach will operate following the NinjaScript strategy, but not the ATM strategy that is initiated from the NinjaScript strategy.

      Using ATM Strategies - https://ninjatrader.com/support/help...strategies.htm

      ATM Strategy Methods - https://ninjatrader.com/support/help...gy_methods.htm

      Let us know if you have any questions.
      JimNinjaTrader Customer Service

      Comment


        #4
        So, is there a way to have the strategy know what's the net profit of one of my accounts when using atm?
        Also, what solution could I use in this case to have the strategy not take orders for xtime or x bars after an order has been placed?

        Comment


          #5
          Hello OsvaldoVision,

          The ATM strategy methods would be used to get the Realized and Unrealized PnL for the ATM strategy. For checking the Unrealized PnL of the account, you could use PositionAccount. For checking the daily realized PnL of an account, Account.Get can be used.

          PositionAccount - https://ninjatrader.com/support/help...ionaccount.htm

          Acount.Get - https://ninjatrader.com/support/helpGuides/nt8/get.htm

          AccountItems - https://ninjatrader.com/support/help...ccountitem.htm

          You could use your own variables to store CurrentBar when the order is submitted so you can count how many bars have passed since the entry order was placed. Although, if you wish to use these Managed Approach methods like BarsSinceEntryExecution and BarsSinceExitExecutiuon, I may suggest implementing the logic which would be handled by the ATM strategy within the NinjaScript strategy instead.

          We look forward to being of further assistance.
          JimNinjaTrader Customer Service

          Comment


            #6
            Thank you! This sounds like a solution. I've set print statements for today and I'll come back later today once I code it to let you know if it achieved the intended goal

            Comment


              #7
              Hi, related to this, I noticed thr strategy was selling orders but it should only buy orders, so enter long with atm
              The only entry order is the atm one which I have setup as:

              AtmStrategyCreate(OrderAction.Buy, OrderType.Limit, High[0], 0, TimeInForce.Day, orderId, "NQ 2", atmStrategyId, (atmCallbackErrorCode, atmCallBackId)

              Am I missing something? It is mostly opening short trades

              Comment


                #8
                Hello OsvaldoVision,

                I would recommend recompiling NinjaScripts and then to remove/re-add the strategy to ensure you are testing with a current version. Add a print above AtmStrategyCreate so you can be sure your logic is hitting this method when the order is submitted. Please also ensure that your Siim101 account is flat on this instrument when you are testing.

                We should see a print when the entry order for the ATM strategy is submitted and it should be a Buy Limit entry.

                If you see that the strategy has entered a short position, please right click on the strategy in the Strategies tab of the Control Center and select Strategy Performance > Realtime. If you see any orders here, they would be submitted from Managed Approach or Unmanaged Approach NinjaScript Strategy code, and would not have been associated with the ATM strategy.

                I may also suggest testing with a new modification of the SampleAtmStrategy example that comes with NinjaTrader that can be used as a test. This can help to narrow down other logic in your strategy that may be submitting orders.

                You can also comment out sections of code until the behavior is no longer seen, and uncomment that section of code to confirm where a short order has been placed.

                Debugging Tips - https://ninjatrader.com/support/help...script_cod.htm

                We look forward to assisting.
                JimNinjaTrader Customer Service

                Comment


                  #9
                  Hello! Thank you so much! I'll definitely looo into that
                  In the meantime I mangednto code the atm into NT8 (close enough). It's not a permanent solution since I want to properly call the atm but I need to study it. Thanks for providing assistance and resources!!

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by RookieTrader, Today, 07:41 AM
                  1 response
                  4 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by kujista, Today, 05:44 AM
                  1 response
                  9 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by elderan, Yesterday, 08:03 PM
                  1 response
                  12 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Started by samish18, Yesterday, 08:57 AM
                  8 responses
                  25 views
                  0 likes
                  Last Post samish18  
                  Started by DJ888, 04-16-2024, 06:09 PM
                  3 responses
                  10 views
                  0 likes
                  Last Post NinjaTrader_Erick  
                  Working...
                  X