Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Position.MarketPosition == MarketPosition.Flat not working

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

    Position.MarketPosition == MarketPosition.Flat not working


    I would like to place orders only when my current position is flat.
    I am using the below condition for that.
    Position.MarketPosition == MarketPosition.Flat

    I am using the ATMstrategy template names to place the orders within my strategy.

    The strategy places the trade even though I am currently in a position.
    Please help.




    #2
    Have you studied the SampleAtmStrategy provided as an example by Ninjatrader? It is all there.

    Comment


      #3
      Hello pvincent,

      When using ATM's you cannot use any of the strategy based properties or methods like strategy position. you can use the methods shown here with ATM's: https://ninjatrader.com/support/help...gy_methods.htm

      You can use the SampleATMStrategy as a starting point, that shows how you can limit to a single entry at a time.

      Comment


        #4
        Can I use PositionAccount.MarketPosition == MarketPosition.Flat

        Comment


          #5
          Hello pvincent,

          No, that is for a strategy based position. ATM's are external to a NinjaScript strategy so it can only use the methods in the link I had provided.

          Comment


            #6
            Thank you.

            Comment


              #7
              Originally posted by trendisyourfriend View Post
              Have you studied the SampleAtmStrategy provided as an example by Ninjatrader? It is all there.
              Can you send me the screenshot where in the SampleAtmStrategy is checking for current position as flat before placing the order?
              Last edited by pvincent; 03-25-2022, 03:11 PM.

              Comment


                #8
                Hello pvincent,

                The sample does not check the position at all, it uses the ID variable for the strategy to check if that is populated or not. That would be lines 59 and 76 in the sample. The sample sets the order ID back to empty when the atm is not present: orderId = string.Empty;

                Comment


                  #9
                  Originally posted by NinjaTrader_Jesse View Post
                  Hello pvincent,

                  No, that is for a strategy based position. ATM's are external to a NinjaScript strategy so it can only use the methods in the link I had provided.
                  Hi Jesse,

                  I would like to check whether my current position is flat before placing an order using the ATMstrategy.
                  For example, I have a trigger and order was placed for a buy.
                  Now, I get a second trigger but I am already long, so I don't want to place the new trade.


                  Comment


                    #10
                    Hello pvincent,

                    You would need to use the order id variable for that, the ATM does not work like a strategy which has a position variable. The ATM is an external strategy so you need to use the means shown in the sample if you mean to limit the atm to be submitted once. It does not matter if the position is long or short, the order id variable being populated means there is an active ATM so the entry logic is ignored.

                    The alternative is to use GetAtmStrategyPositionQuantity() or GetAtmStrategyEntryOrderStatus() to check if the entry was filled however you still need the exact same code from the sample to do that and to prevent any other entries from being submitted before you can check. The sample logic is really the besst way to handle submitting a single ATM until its complete and then resetting.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by NullPointStrategies, Yesterday, 05:17 AM
                    0 responses
                    56 views
                    0 likes
                    Last Post NullPointStrategies  
                    Started by argusthome, 03-08-2026, 10:06 AM
                    0 responses
                    132 views
                    0 likes
                    Last Post argusthome  
                    Started by NabilKhattabi, 03-06-2026, 11:18 AM
                    0 responses
                    73 views
                    0 likes
                    Last Post NabilKhattabi  
                    Started by Deep42, 03-06-2026, 12:28 AM
                    0 responses
                    45 views
                    0 likes
                    Last Post Deep42
                    by Deep42
                     
                    Started by TheRealMorford, 03-05-2026, 06:15 PM
                    0 responses
                    49 views
                    0 likes
                    Last Post TheRealMorford  
                    Working...
                    X