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 Hwop38, 05-04-2026, 07:02 PM
    0 responses
    173 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    328 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    252 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    354 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    181 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X