Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Account.Orders is always empty

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

    Account.Orders is always empty

    Hi,

    I have the following code in an IsUnmanaged = true strategy.

    Code:
    if (UseTrailingStop && Position.MarketPosition != MarketPosition.Flat)
    {
    lock(Account.Orders)
    {
    Print("Checking trailstop Account.Orders.Count = " + Account.Orders.Count) ;
    foreach (Order Worder in Account.Orders) // loop through orders
    So, the code only executes if MarketPosition is not flat. As you would expect, when there is a position that has been created with SubmitOrderUnmanaged, the 'Checking trailstop' Print does Print. The issue is that Account.Orders is always empty. The Count is zero, and the loop through the orders does not execute. Even with Unmanged orders, I'd expect to be able to iterate through those resting orders. Is this not the case? I know the orders (stops) are resting when this code executes as in backtest, the stops are hit and the orders shown on the backtest chart. It is in backtest mode I am running this code. I have verified that a take profit order and stop order have been submitted prior with SubmitOrderUnmanaged - They just do not appear to show in the Account.Orders collection during a run in the strategy analyzer.

    Is there an obvious issue here?

    Thanks.​

    #2
    Hello pjsmith,

    Thanks for your post.

    From the Account.Orders help guide page: "Please keep in mind that orders placed when in State.Historical are not submitted live to an account."

    Account.Orders: https://ninjatrader.com/support/help...rs_account.htm

    The Strategy Analyzer uses Historical data to backtest strategies to see how they may behave and it does not have a specific account tied to it. Historical orders will not be submitted to an account so the value would return 0.

    You could consider testing your strategy using the Playback connection with Market Replay data instead of using the Strategy Analyzer.

    Playback: https://ninjatrader.com/support/help...8/playback.htm
    <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
      Ah, OK - thank you. I did see this, but did not believe State == State.Historical during backtesting.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Mindset, 04-21-2026, 06:46 AM
      0 responses
      88 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      135 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      68 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      119 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      69 views
      0 likes
      Last Post PaulMohn  
      Working...
      X