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

Timer to remove alert after x seconds

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

    Timer to remove alert after x seconds

    Hi all,
    I have an indicator that alerts when a calculated volume level is exceeded and displays text on the chart. What I would like is, to have the text(alert) removed from the chart after say 15 seconds from when it triggered. I have looked at the BarTimer but can't understand how to get that to work for this.

    As always, your help is appreciated!

    #2
    You could trigger a timerevent that would run irregardless if there is data coming through on the chart.



    Easier option would be to store the time and do a check to see if 15 seconds has lapsed.



    Comment


      #3
      Would the second (easier) option work in market replay as well? Does it get time from NinjaTrader or the PC?

      Thanks!

      Comment


        #4
        That uses market replay.

        Comment


          #5
          Great! Thank you

          Comment


            #6
            Having trouble getting the time variable when it triggers. Here is the code I'm using...

            timer = ToTime(Time[0]);
            Print ("Time is " + timer);

            The output from the Print command returns the time but with 00 seconds, can't seem to store the seconds. Here's the output window text....

            Time is 90100

            The actual time it triggered at was 9:00:19 AM

            Comment


              #7
              It looks like it will be an issue.

              Post #8 from NT_PatrickH explains how to get around it.

              Comment


                #8
                Originally posted by mlarocco View Post
                Having trouble getting the time variable when it triggers. Here is the code I'm using...

                timer = ToTime(Time[0]);
                Print ("Time is " + timer);

                The output from the Print command returns the time but with 00 seconds, can't seem to store the seconds. Here's the output window text....

                Time is 90100

                The actual time it triggered at was 9:00:19 AM
                What timeframe is the chart?

                Comment


                  #9
                  I am using a 1 minute chart. Apparently, this is normal behavior. I was able to add the time period for a 1 second chart and then count the bars after the alert was triggered.....


                  Add(PeriodType.Second, 1);

                  if (timer == 0)
                  timer = CurrentBars[1];

                  if (My Condition)
                  {
                  timer = CurrentBars[1];
                  }

                  if ((timer + 15) == CurrentBars[1])
                  {
                  RemoveDrawObject("Trigger");
                  }


                  Works great

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by nandhumca, Yesterday, 03:41 PM
                  1 response
                  12 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by The_Sec, Yesterday, 03:37 PM
                  1 response
                  11 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by vecnopus, Today, 06:15 AM
                  0 responses
                  1 view
                  0 likes
                  Last Post vecnopus  
                  Started by Aviram Y, Today, 05:29 AM
                  0 responses
                  5 views
                  0 likes
                  Last Post Aviram Y  
                  Started by quantismo, 04-17-2024, 05:13 PM
                  3 responses
                  27 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Working...
                  X