Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Alert Manager

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

    #16
    Hello oceanis400,

    Working with the collection would just require using any C# means to find the element you want. That won't be specific to NinjaScript so you can find examples of selecting elements from a KeyValuePair in external C# resources. I would suggest searching online for "C# KeyValuePair linq examples" or "C# linq" to have a more firm understanding of working with this type of collection or selecting elements.

    One method you may be able to use here is the LastOrDefault:

    Code:
    KeyValuePair<string, IEnumerable<AlertEventArgs>> alert = NinjaTrader.NinjaScript.Alert.AlertHistory.LastOrDefault();
    You could give this a try and see if that returns the correct alert, I have not tested this as I don't currently have any alerts set up.

    Another approach is to keep using the loop and put that in a method, that would be if you need to call this in multiple areas. The loop is really not going to be that bad unless you are doing a lot of work inside the loop and there are many alerts. If you are just looping to select the last item that won't really hurt performance as you are not doing any work in the loop.


    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    104 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    52 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    34 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    38 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    74 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X