Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Alert Manager

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

    Alert Manager

    hello,

    Is there a way to record all alert tab to file without using export command.
    Just to have a log file with all alert every day.
    if no , using API to do it?

    thank you

    #2
    Hello oceanis400,

    Welcome to the NinjaTrader support forum.

    There is no way to do this from the user interface. There is also no documented or supported way to do this from code, but it looks like you can access the alert history by using the following syntax:


    Code:
    foreach (KeyValuePair<string, IEnumerable<AlertEventArgs>> alert in NinjaTrader.NinjaScript.Alert.AlertHistory)
    {
          Print(alert.Key + " Count: " + alert.Value.Count());
          IEnumerable<AlertEventArgs> vals = alert.Value;
    
          foreach (AlertEventArgs alertEventArgse in vals)
          {
              Print(alertEventArgse.Message + " " + alertEventArgse.Instrument.FullName);
          }
    }

    Please let me know if I may be of further assistance.
    Last edited by NinjaTrader_Jesse; 03-05-2020, 02:39 PM. Reason: add count to print
    JesseNinjaTrader Customer Service

    Comment


      #3
      hello,

      Thank you for this code.

      But I would like get alerts just one time in an indicator. (for example from last bar update)

      If I use "foreach" in OnBarUpdate() , I have all alerts several time on each bar.

      I test many time different code an I haven't a good result.

      thank you to help me

      Comment


        #4
        Hello oceanis400,

        Thank you for the reply.

        You could further refine the syntax provided to your needs such as outputting the information once. What have you tried so far that is not working?

        While I wouldn't be able to build an entire indicator that does this for you I could try to recommend corrections on what you are doing that is failing.

        You could possibly use the Count property logically to control when this happens or also the state system.


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          hello Jesse,

          I try to explain better. (your code is working)
          If I call your code with foreach , I have all alerts on each bar.
          How you use property Count with Alerthistory. (This is no help on this)

          I would like just call your code once per bar (inside OnBarUpdate()).
          But I need to know how many alert are logged.

          Is it possible to print output in points and not in float ? (for example for future 10Years TBOND)

          sincerely,

          Comment


            #6
            Hello oceanis400,

            Thank you for the reply.

            Correct if you call this on each bar, it will complete the loop on each bar, you would need to use logic to further filter the alerts if you only want to see new alerts.

            It sounds like you are already calling this on each bar but want less alerts on each bar, is this correct? if so that is something you would have to add in logically. This collection simply shows all of the alerts when you loop over it.

            Regarding printing in points, are you asking how to convert a price into points and then print that? can you provide more detail on what you are trying to convert to points?



            Please let me know if I may be of additional assistance.

            JesseNinjaTrader Customer Service

            Comment


              #7
              Hello Jesse,

              I improve my code , but is it possible to read alert each second in 1min chart ? (I need to stay in 1min chart of course)
              I'm using OnBarUpdate() but I would like to log alert to file more quickly than 1 min.

              Comment


                #8
                Hello oceanis400,

                If you are using a 1 minute series, the most frequent your logic will be called is at the frequency of 1 minute. You would need to use a lesser series such as 1 second if you wanted specifically 1 second intervals. The alternative would be to execute the code OnEachTick. In that case, you could achieve 1 second intervals by checking the current ticks Time and doing math to see if that was more than 1 second since the last time you executed the loop.

                I look forward to being of further assistance.
                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Hello Jesse, I have the same request, How do I get to the Count property
                  it is not in: alert.Count or Alert.Count or NinjaTrader.NinjaScript.Alert.AlertHistory.Count
                  Thanks

                  Comment


                    #10
                    OK apparently I misspelled something, got it printing out now but it is just 1, even tho the log has dozens of items.

                    Comment


                      #11
                      Hello kenz987,

                      It looks like there was a mistake in my prior post and I didn't get the full print copied over that includes using the key with the dictionary. Because printing the count otherwise requires the sample from post 2 I have just updated that post instead to include the count in the existing print. The part you are missing is that the Count needs to be within the loop shown in #2. The collection with the alerts will reside in another collection for the workspaces where the alerts originated.

                      Please let me know if I may be of further assistance.
                      JesseNinjaTrader Customer Service

                      Comment


                        #12
                        Thanks Jessee, That worked. I dont understand all the convoluted C-sharp syntax, but as long as it works Im OK.
                        I know this is an old thread, but thanks also to oceanis400 for the original post. This kind of stuff is not in the help system, so having someone go first is a big help. Did you ever figure out the more frequent intervals, maybe use a timer loop. Thanks All.

                        Comment


                          #13
                          One more question: How to retrieve the background color of the alert message?

                          Comment


                            #14
                            Hello kenz987,

                            If you are referring to the previous sample with the loop, you can try accessing the alertEventArgse.Background property.


                            I look forward to being of further assistance.
                            JesseNinjaTrader Customer Service

                            Comment


                              #15
                              hello Jesse,

                              Is there a way to read only Last alert with this code:
                              foreach (KeyValuePair<string, IEnumerable<AlertEventArgs>> alert in NinjaTrader.NinjaScript.Alert.AlertHistory) { Print(alert.Key + " Count: " + alert.Value.Count()); IEnumerable<AlertEventArgs> vals = alert.Value; foreach (AlertEventArgs alertEventArgse in vals) { Print(alertEventArgse.Message + " " + alertEventArgse.Instrument.FullName); } }

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by arvidvanstaey, Today, 02:19 PM
                              4 responses
                              11 views
                              0 likes
                              Last Post arvidvanstaey  
                              Started by samish18, 04-17-2024, 08:57 AM
                              16 responses
                              61 views
                              0 likes
                              Last Post samish18  
                              Started by jordanq2, Today, 03:10 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post jordanq2  
                              Started by traderqz, Today, 12:06 AM
                              10 responses
                              18 views
                              0 likes
                              Last Post traderqz  
                              Started by algospoke, 04-17-2024, 06:40 PM
                              5 responses
                              48 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X