• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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.

    http://ninjatrader.com/support/helpG...ustomevent.htm

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

    http://ninjatrader.com/support/helpG...t7/?totime.htm

    https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

    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.

              http://ninjatrader.com/support/forum...seconds+totime

              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 canuck, Yesterday, 07:52 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post canuck
                  by canuck
                   
                  Started by itrader46, 10-21-2019, 11:12 PM
                  2 responses
                  20 views
                  0 likes
                  Last Post koganam
                  by koganam
                   
                  Started by walter739, Yesterday, 06:04 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post walter739  
                  Started by MarkWise, Yesterday, 03:04 PM
                  2 responses
                  9 views
                  0 likes
                  Last Post MarkWise  
                  Started by maltese, Yesterday, 02:38 PM
                  2 responses
                  12 views
                  0 likes
                  Last Post maltese
                  by maltese
                   
                  Working...
                  X