Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Harry, 05-02-2018, 01:54 PM
    10 responses
    3,203 views
    0 likes
    Last Post tharton3  
    Started by cre8able, Yesterday, 01:16 PM
    3 responses
    11 views
    0 likes
    Last Post cre8able  
    Started by ChartTourist, Today, 08:22 AM
    0 responses
    6 views
    0 likes
    Last Post ChartTourist  
    Started by LiamTwine, Today, 08:10 AM
    0 responses
    2 views
    0 likes
    Last Post LiamTwine  
    Started by Balage0922, Today, 07:38 AM
    0 responses
    5 views
    0 likes
    Last Post Balage0922  
    Working...
    X