Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How do I create indicator using time.

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

    How do I create indicator using time.

    I would like to be able to set up and indicator that does this:

    When time = User Defined Input
    then do something.

    For instance, if time = 8:00am then sound alert.

    I am assuming that this can be done by referencing the clock and independent of
    what type of bars are used.

    Thanks.

    #2
    Hello billr,

    You may read the following forum post that goes over how to use time filters.
    http://www.ninjatrader.com/support/f...ead.php?t=3226

    Here is an example:

    Code:
    // if the Local PC Clock is 8:00am or later
    if (ToTime(Time[0]) >= 80000)
    {
        // Do Something
    }
    Yes, it would get the time stamp of the bar. See the following link for more information about Time[].
    http://www.ninjatrader.com/support/h....html?time.htm

    Please let me know if I can be of further assistance.
    JCNinjaTrader Customer Service

    Comment


      #3
      I was wondering if you could clarify what is happening using your
      example:

      ToTime(Time[0]) >= 80000

      Does this mean it is looking for the time stamp for the current bar (Time[0]) to
      compare to 80000? If so, I prefer not to rely on my bars to close to check time. I would
      like to simply check the clock and if it is a certain time then do something. (independent of bars)

      Example:
      //if it is 8:00am, I want to then draw vertical line on chart at 8:00:00 time axis. Even if I am in the middle of a 5000V bar for instance.

      If local PC clock = 80000
      then draw vertical line at 8:00:00 on chart time axis.

      Could I use your syntax and set CalulateOnBarClose to false?

      If so, this begs another question: If the "if" is true and it is 8:00:00, then if I simply instruct NT to draw a vertical line (or something else), will it correctly place it at 8:00:00 location on the chart?

      Thanks.

      Comment


        #4
        Hello billr,

        Correct, it returns a value representing time based on the current bars time stamp. The following link has more information on ToTime().
        http://www.ninjatrader.com/support/h...tml?totime.htm

        If you do not want to use the time stamps of a bar then you could create a custom event so you do not need to wait on the next incoming tick or next bar before your code gets calculated.You may view the following forum post that gives you a reference sample of how to create custom events.
        http://www.ninjatrader.com/support/f...ead.php?t=5965

        CalculateOnBarClose (COBC) still requires incoming data for your indicator/strategy to be calculated. See the following link for more information on COBC. http://www.ninjatrader.com/support/h...onbarclose.htm

        Inside the if() statement you can use the DrawVerticleLine() or any other object/action you would like to calculate or do. Here is a link that goes over the DrawVerticleLine().
        http://www.ninjatrader.com/support/h...rticalline.htm

        Please let me know if I can be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          I think I'm dancing around what I am trying to do. I want to be able to program a marker or alert feature for known news events (not a live feed). So each morning, I can manually plug times into an indicator's settings and when that time arrives during the day, the indicator will trigger an alert, reminding me of news or other events I want to track. Can that be done?

          What I do not want to happen is plugging in a time for an event, and due to the fact that the indicator is tied to time stamps, it fails to trigger in time. For instance, if I have a 60 min chart, I don't want to wait up to 60 mins to get an alert I set for a time that occurred within that bar.

          Comment


            #6
            Hello billr,

            Yes that is possible by using a custom event.

            Originally posted by NinjaTrader_JC View Post
            If you do not want to use the time stamps of a bar then you could create a custom event so you do not need to wait on the next incoming tick or next bar before your code gets calculated.You may view the following forum post that gives you a reference sample of how to create custom events.
            http://www.ninjatrader.com/support/f...ead.php?t=5965
            By using a custom event you can specify a time in milliseconds in that will run no matter if Live data is coming in.

            Please let me know if I can be of further assistance.
            JCNinjaTrader Customer Service

            Comment


              #7
              I'm afraid that is beyond my coding knowledge. But thanks.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Kensonprib, 04-28-2021, 10:11 AM
              5 responses
              191 views
              0 likes
              Last Post Hasadafa  
              Started by GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,230 views
              0 likes
              Last Post xiinteractive  
              Started by andrewtrades, Today, 04:57 PM
              1 response
              14 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by chbruno, Today, 04:10 PM
              0 responses
              7 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              441 views
              0 likes
              Last Post Delerium  
              Working...
              X