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

GetAtmStrategyMarketPosition returns MarketPosition.Flat if I manually cancel OCO

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

    GetAtmStrategyMarketPosition returns MarketPosition.Flat if I manually cancel OCO

    Hello,

    I can handle an ATM position until I cancel manually either stop or limit orders.
    The position is still open but GetAtmStrategyMarketPosition(atmStrategyId) returns Flat, and I lose control of this atm strategy.
    Please advise.

    #2
    Hello frslvr,

    Thank you for your post.

    When you are in a position and are using an ATM Strategy to place a profit target/stop-loss and you manually cancel the profit target or stop-loss orders, you are effectively canceling the ATM Strategy. If the ATM Strategy does not exist then MarketPosition.Flat returns as seen in the Notes section of the GetAtmStrategyMarketPosition help guide linked below.

    Please note that GetAtmStrategyMarketPosition provides access to the current ATM strategy position, which should not be confused with the NinjaScript strategy position or account position.

    Here is the help guide about GetAtmStrategyMarketPosition for more information - https://ninjatrader.com/support/help...etposition.htm

    Please let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your answer, Brandon.

      Is it possible to close the open position (or all positions) on or after the ATM destroyed?

      Comment


        #4
        Hello frslvr,

        Thank you for your note.

        You could check if your account is not flat with PositionAccount by checking if (PositionAccount.MarketPosition == MarketPosition.Flat). Then check if the AtmStrategy has active target/stops that are unprotected by using GetAtmStrategyStopTargetOrderStatus("Stop1", idValue) to look for a stop order since an ATM strategy can be made without a Target but must include a Stop. If Stop1 does not exist, you could assume the Target/Stop is not active. Finally, use AddOn Framework to close the position if it is unprotected. To submit an order directly to the account, you could use CreateOrder to create an order and submit that order directly to the account by calling <Account>.Submit.

        Or, you could simply click the Close button in Chart Trader after you manually close the Profit Target/Stop-Loss.

        Please see the help guide links below for more information about using the AddOn approach.

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

        GetAtmStrategyStopTargetOrderStatus - https://ninjatrader.com/support/help...rgetorders.htm

        Submit - https://ninjatrader.com/support/help...nt8/submit.htm

        Let us know if we may assist further.
        Brandon H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Javierw.ok, Today, 04:12 PM
        0 responses
        2 views
        0 likes
        Last Post Javierw.ok  
        Started by timmbbo, Today, 08:59 AM
        2 responses
        10 views
        0 likes
        Last Post bltdavid  
        Started by alifarahani, Today, 09:40 AM
        6 responses
        40 views
        0 likes
        Last Post alifarahani  
        Started by Waxavi, Today, 02:10 AM
        1 response
        18 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by Kaledus, Today, 01:29 PM
        5 responses
        15 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X