Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strange issue with AllTrades

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

    Strange issue with AllTrades

    Hi,

    My code returns SystemPerformance.AllTrades count as zero in one file and in another file it is working as expected. Both files have exact same code but the behaviour of AllTrades is different. I see TradeCount is increasing and cumprofit is also reflecting fine but when i try to retrieve last trade then it throws index out of range on the first file

    if(SystemPerformance.AllTrades.TradesCount>0)
    lastTrade = SystemPerformance.AllTrades[SystemPerformance.AllTrades.TradesCount - 1]; (works in one .cs file but not in other)

    I'm lost, appreciate any help.​

    #2
    Hello nagesh789,

    Thanks for your post.

    To clarify, are you using the same exact code in both .cs files?

    Have taken debugging steps by reducing the code and adding prints to confirm the 'Index out of range' error message is being thrown by this line of code?

    If you comment out these lines of code, do you still see the 'Index out of range' error appearing when running the script?

    Please share a simple reduced test script with us that demonstrates the behavior you are reporting so we may look into this matter further.

    Note that a reduced copy refers to a copy of the script that contains the minimum amount of code needed to reproduce the issue. All other code is commented out or removed.

    To create a copy of your script to modify, open a New > NinjaScript Editor, select your script, right-click in the Editor, select 'Save as', name the script, and click OK.​

    To export the script, go to Tools > Export > NinjaScript AddOn.
    <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
    52 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
    43 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    47 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X