Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ATM unmanaged strategy status sequence for MarketPosition Flat to Long or Short?

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

    ATM unmanaged strategy status sequence for MarketPosition Flat to Long or Short?

    When using ATM and GetAtmStrategyEntryOrderStatus(OrderId) waiting for the status to be "Filled" the OrderId is set to string.empty and the order status[2] == "Filled" occurs, when is Position.MarketPosition == MarketPosition changed?

    Is it within the current OnBarUpdate() with the sequence of conditions that the Strategy has implement?

    If the Strategy is using Calculate == Calculate.OnBarClose does it to check for both ATM OrderId is "Filled" and MarketPosition is not "Flat"?


    #2
    Hello Tonofit,

    Thanks for your post.

    Once an entry order is filled, Position.MarketPosition will reflect your current market position. For example, if a long entry order is filled, Position.MarketPosition will be MarketPosition.Long. If a short entry order is filled, Position.MarketPosition will be MarketPosition.Short.

    When using Calculate.OnBarClose, the strategy OnBarUpdate() method will only run when a bar has closed.

    See this help guide page for more information about Calculate: https://ninjatrader.com/support/help.../calculate.htm

    This means that all of the strategy's OnBarUpdate() logic will process once at the close of each bar.

    A strategy uses GetATMStrategyEntryOrderStatus() and Calculate.OnBarClose will get the current state of the specified entry order at the close of each bar. You could print out the current state to see the state of the entry order status.

    See this help guide page for more information and sample code: https://ninjatrader.com/support/help...rderstatus.htm

    A strategy that uses Calculate.OnBarClose and contains a condition to check if Position.MarketPosition == MarketPosition Flat, this condition will process once at the close of each bar. You could test this by printing out Position.MarketPosition in your script to see the market position of your strategy.

    See this help guide page for more information about Position.MarketPosition: https://ninjatrader.com/support/help...etposition.htm

    Let me know if I may assist further.
    Last edited by NinjaTrader_BrandonH; 09-09-2022, 11:50 AM.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      For Calculate.OnBarClose using unamanged ATM and the strategy comes from builder but is unlocked code, so that ATM code can be used.

      If I have a short position and get stopped out, and then want to re-enter a new position (short or long) should it be done by checking the strategy id like this and resetting my logic state user variables GO_LONG = false; GO_SHORT = false

      // If the strategy has terminated reset the strategy id.
      if (shortAtmId.Length > 0 && GetAtmStrategyMarketPosition(shortAtmId) == Cbi.MarketPosition.Flat)
      {
      GO_LONG = false;
      GO_SHORT = false;
      }

      Or should I use (Position.MarketPosition == MarketPosition.Flat) where it won't take place until the bar following the current bar from what I'm understanding.

      if (Position.MarketPosition == MarketPosition.Flat)
      {
      GO_LONG = false;
      GO_SHORT = false;
      }

      Comment


        #4
        Hello Tonofit,

        Thanks for your note.

        If you would like to place a long or short order when you are in a flat position, you could create a condition that checks if Position.MarketPosition == MarketPosition.Flat and set your bools within that condition.

        Then, you could create a condition that checks if the bools are true or false and call your order entry method accordingly to place the long/short order.

        Let me know if I may assist further.

        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        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