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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    30 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    40 views
    0 likes
    Last Post CarlTrading  
    Working...
    X