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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    90 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
    120 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