Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Issue getting market position size in Market Replay

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

    Issue getting market position size in Market Replay

    Hello,

    I'm currently testing out a strategy using Market Replay and I'm using the following to open a new ATM order

    entryOrder = account.CreateOrder(instrument, OrderAction.Buy, OrderType.Market, OrderEntry.Automated, TimeInForce.Day, 1, 0, 0, string.Empty, "Entry", Core.Globals.MaxDate, null);
    NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrate gy("ATMBACKTEST", entryOrder);

    This opens the order fine, at this point I want to enter the below if statement and run some logic but Position.MarketPosition is always "Flat", even when it's in a position.

    If (Position.MarketPosition == MarketPosition.Flat)
    {
    //do some stuff here
    }​
    else
    {
    // do this stuff
    }

    Is there another way I can do this? or is the above incorrect? Should Position.MarketPosition be updated or does this not happen in Market Replay?

    Hopefully I've explained this correctly.


    Many Thanks for your help

    Andy

    #2
    Use https://ninjatrader.com/support/help...etposition.htm instead. You will want to read that entire section of the help regarding using ATM strategy methods carefully.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Hi Bruce,

      thanks, I’ll take a look into this again.

      I did find this and I tried to get it to work but wasn’t sure what “Id” to pass it, are your able to tell me which ID I need to pass? Tried passing the ATM strategy ID with no luck!

      thank you

      Comment


        #4
        You should be using https://ninjatrader.com/support/help...gyuniqueid.htm to get a unique ID for both the ATM strategy instance itself and the entry order (two different ones), and then pass in the strategy instance one as the id when you are trying to get the position. You can't just call every one "ATM BACKTEST". Use https://ninjatrader.com/support/help...tegycreate.htm to create the ATM strategy instance, not the way you are doing it there. On that same help page, there is an example of how to start one properly.
        Bruce DeVault
        QuantKey Trading Vendor Services
        NinjaTrader Ecosystem Vendor - QuantKey

        Comment


          #5
          Hello Andy,

          Thank you for your post.

          It appears you are using the Account class in your script to submit orders. For a detailed example that uses the Account class, I suggest checking out the AddOn Framework NinjaScript Basic file that is linked on the following page:This example demonstrates the use of GetAtmStrategyMarketPosition. For more details on using ATM strategies within NinjaScript, please see the following overview:Please let us know if we may be of further assistance.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          50 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          126 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          69 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          42 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X