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 NullPointStrategies, Today, 05:17 AM
      0 responses
      53 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      130 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      70 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      44 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