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.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by andrewtrades, Today, 04:57 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by chbruno, Today, 04:10 PM
    0 responses
    6 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by josh18955, 03-25-2023, 11:16 AM
    6 responses
    436 views
    0 likes
    Last Post Delerium  
    Started by FAQtrader, Today, 03:35 PM
    0 responses
    7 views
    0 likes
    Last Post FAQtrader  
    Started by rocketman7, Today, 09:41 AM
    5 responses
    19 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X